Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 2.7 Python:在提升模式下运行自动化脚本的一部分_Python 2.7_Pywin32_Elevated Privileges_Shellexecuteex - Fatal编程技术网

Python 2.7 Python:在提升模式下运行自动化脚本的一部分

Python 2.7 Python:在提升模式下运行自动化脚本的一部分,python-2.7,pywin32,elevated-privileges,shellexecuteex,Python 2.7,Pywin32,Elevated Privileges,Shellexecuteex,我正在运行一些自动化测试,一些部件必须在提升模式下运行才能工作。这很好;我正在使用pywin32库中的shell.ShellExecuteEx调用我自己的脚本,这很好 以下是我正在使用的确切参数: shell.ShellExecuteEx( nShow=win32con.SW_SHOWNORMAL, fMask=win32com.shell.shellcon.SEE_MASK_NOCLOSEPROCESS,

我正在运行一些自动化测试,一些部件必须在提升模式下运行才能工作。这很好;我正在使用pywin32库中的shell.ShellExecuteEx调用我自己的脚本,这很好

以下是我正在使用的确切参数:

shell.ShellExecuteEx(
                     nShow=win32con.SW_SHOWNORMAL,
                     fMask=win32com.shell.shellcon.SEE_MASK_NOCLOSEPROCESS,
                     lpVerb='runas', 
                     lpFile='<path to executable>',
                     lpParameters='<parameter string>'
                     )
shell.ShellExecuteEx(
nShow=win32con.SW_SHOWNORMAL,
fMask=win32com.shell.shellcon.SEE\u MASK\u NOCLOSEPROCESS,
lpVerb='runas',
lpFile=“”,
lpParameters=''
)
到目前为止,我的方法是将整个自动化代码放在一个模块中,然后以提升的权限调用该模块

然而,我的一些代码只有在没有在提升模式下运行时才能工作。 我必须在两者之间切换。我怎样才能做到这一点