Skip to content

Instantly share code, notes, and snippets.

@bobismijnnaam
Created September 30, 2015 15:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bobismijnnaam/ed4772a126e973c890cc to your computer and use it in GitHub Desktop.
Save bobismijnnaam/ed4772a126e973c890cc to your computer and use it in GitHub Desktop.
Starts a process hidden, inheriting permissions.
from win32com.shell import shell
import os
fileDir = os.path.dirname(os.path.realpath(__file__)) + "\\start.bat"
OPEN_NORMAL = 5
OPEN_HIDDEN = 0
a = shell.ShellExecuteEx(
# "runas" is also nice, to request admin rights before starting. See MSDN docs on ShellExecuteEx for details.
lpVerb = "open",
# Right now it just launches a batch file in the same folder as the .py file, but if you want to customize, this is probably the droid you're looking for.
lpFile = fileDir,
# Change the following to change the behaviour of the opened window. E.g. OPEN_HIDEN will run the process invisibly, while OPEN_NORMAL will just show the window. See the MSDN docs on ShellExecuteEx for details.
nShow=OPEN_HIDDEN
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment