Running the program with Python as hidden

I want to run .exe files hidden in Windows using Python. I used the following commands,but the hidden program does not run.

from subprocess_maximize import Popen

Popen(r"C:\Apps\test.exe",show='hidden', priority=1)

Upvotes: 0

Views: 984

Answers (1)

user16858520
user16858520

Reputation:

if you want python hide cmd console Use :

import win32gui, win32con

hide = win32gui.GetForegroundWindow()
win32gui.ShowWindow(hide , win32con.SW_HIDE)

or if you want to hide cmd from python use :

import ctypes
ctypes.windll.user32.ShowWindow( ctypes.windll.kernel32.GetConsoleWindow(), 6 )

Else Save the program with a .pyw extension and now it will open with pythonw.exe No shell or cmd window

Upvotes: 2

Related Questions