Use cmd /c with runas on Windows to allow compound commands

This commit is contained in:
twangboy 2024-09-20 10:57:48 -06:00 committed by Daniel Wozniak
parent ab9e02a1a9
commit 8c8792d81b

View file

@ -209,7 +209,7 @@ def runas(cmdLine, username, password=None, cwd=None):
int(user_token),
logonflags=1,
applicationname=None,
commandline=cmdLine,
commandline=f'cmd /c "{cmdLine}"',
currentdirectory=cwd,
creationflags=creationflags,
startupinfo=startup_info,
@ -310,7 +310,7 @@ def runas_unpriv(cmd, username, password, cwd=None):
domain=domain,
password=password,
logonflags=salt.platform.win.LOGON_WITH_PROFILE,
commandline=cmd,
commandline=f'cmd /c "{cmd}"',
startupinfo=startup_info,
currentdirectory=cwd,
)