当前位置: 首页>>代码示例>>Python>>正文


Python shell.ShellExecuteEx方法代码示例

本文整理汇总了Python中win32com.shell.shell.ShellExecuteEx方法的典型用法代码示例。如果您正苦于以下问题:Python shell.ShellExecuteEx方法的具体用法?Python shell.ShellExecuteEx怎么用?Python shell.ShellExecuteEx使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在win32com.shell.shell的用法示例。


在下文中一共展示了shell.ShellExecuteEx方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: UseCommandLine

# 需要导入模块: from win32com.shell import shell [as 别名]
# 或者: from win32com.shell.shell import ShellExecuteEx [as 别名]
def UseCommandLine(*classes, **flags):
  unregisterInfo = '--unregister_info' in sys.argv
  unregister = '--unregister' in sys.argv
  flags['quiet'] = flags.get('quiet',0) or '--quiet' in sys.argv
  flags['debug'] = flags.get('debug',0) or '--debug' in sys.argv
  flags['unattended'] = flags.get('unattended',0) or '--unattended' in sys.argv
  if unregisterInfo:
    return UnregisterInfoClasses(*classes, **flags)
  try:
    if unregister:
      UnregisterClasses(*classes, **flags)
    else:
      RegisterClasses(*classes, **flags)
  except win32api.error, exc:
    # If we are on xp+ and have "access denied", retry using
    # ShellExecuteEx with 'runas' verb to force elevation (vista) and/or
    # admin login dialog (vista/xp)
    if flags['unattended'] or exc.winerror != winerror.ERROR_ACCESS_DENIED \
       or sys.getwindowsversion()[0] < 5:
      raise
    ReExecuteElevated(flags) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:23,代码来源:register.py

示例2: ExplorePIDL

# 需要导入模块: from win32com.shell import shell [as 别名]
# 或者: from win32com.shell.shell import ShellExecuteEx [as 别名]
def ExplorePIDL():
    pidl = shell.SHGetSpecialFolderLocation(0, shellcon.CSIDL_DESKTOP)
    print "The desktop is at", shell.SHGetPathFromIDList(pidl)
    shell.ShellExecuteEx(fMask=shellcon.SEE_MASK_NOCLOSEPROCESS,
                         nShow=win32con.SW_NORMAL,
                         lpClass="folder", 
                         lpVerb="explore", 
                         lpIDList=pidl)
    print "Done!" 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:11,代码来源:shellexecuteex.py

示例3: request_admin_privileges

# 需要导入模块: from win32com.shell import shell [as 别名]
# 或者: from win32com.shell.shell import ShellExecuteEx [as 别名]
def request_admin_privileges():
    ASADMIN = 'asadmin'

    if sys.argv[-1] != ASADMIN:
        script = os.path.abspath(sys.argv[0])
        params = ' '.join([script] + sys.argv[1:] + [ASADMIN])
        shell.ShellExecuteEx(lpVerb='runas', lpFile=sys.executable,
                             lpParameters=params, nShow=win32con.SW_SHOW)
        sys.exit(0) 
开发者ID:KanoComputing,项目名称:kano-burners,代码行数:11,代码来源:dependency.py

示例4: launch_console

# 需要导入模块: from win32com.shell import shell [as 别名]
# 或者: from win32com.shell.shell import ShellExecuteEx [as 别名]
def launch_console(params, visible=True, process=sys.executable, visiblity_override=None):
    if visiblity_override is not None:
        if visiblity_override:
            process.replace('pythonw', 'python')
        else:
            process = process.replace('python', 'pythonw').replace('pythonww', 'pythonw')
    try:
        shell.ShellExecuteEx(lpVerb='runas', lpFile=process, lpParameters=params, nShow=5 if visible else 0)
    except pywintypes.error:
        return False
    return True 
开发者ID:Peter92,项目名称:MouseTracks,代码行数:13,代码来源:main.py

示例5: runAsAdmin

# 需要导入模块: from win32com.shell import shell [as 别名]
# 或者: from win32com.shell.shell import ShellExecuteEx [as 别名]
def runAsAdmin(cmdLine=None, wait=True):

    if os.name != 'nt':
        raise RuntimeError, "This function is only implemented on Windows."

    import win32api
    import win32con
    import win32event
    import win32process
    from win32com.shell.shell import ShellExecuteEx
    from win32com.shell import shellcon

    python_exe = sys.executable

    if cmdLine is None:
        cmdLine = [python_exe] + sys.argv
    elif type(cmdLine) not in (types.TupleType, types.ListType):
        raise ValueError, "cmdLine is not a sequence."
    cmd = '"%s"' % (cmdLine[0],)
    # XXX TODO: isn't there a function or something we can call to massage command line params?
    params = " ".join(['"%s"' % (x,) for x in cmdLine[1:]])
    cmdDir = ''
    #showCmd = win32con.SW_SHOWNORMAL
    showCmd = win32con.SW_HIDE
    lpVerb = 'runas'  # causes UAC elevation prompt.

    # print "Running", cmd, params

    # ShellExecute() doesn't seem to allow us to fetch the PID or handle
    # of the process, so we can't get anything useful from it. Therefore
    # the more complex ShellExecuteEx() must be used.

    # procHandle = win32api.ShellExecute(0, lpVerb, cmd, params, cmdDir, showCmd)

    procInfo = ShellExecuteEx(nShow=showCmd,
                              fMask=shellcon.SEE_MASK_NOCLOSEPROCESS,
                              lpVerb=lpVerb,
                              lpFile=cmd,
                              lpParameters=params)

    if wait:
        procHandle = procInfo['hProcess']
        obj = win32event.WaitForSingleObject(procHandle, win32event.INFINITE)
        rc = win32process.GetExitCodeProcess(procHandle)
        # print "Process handle %s returned code %s" % (procHandle, rc)
    else:
        rc = None

    return rc 
开发者ID:ElevenPaths,项目名称:uac-a-mola,代码行数:51,代码来源:admin.py


注:本文中的win32com.shell.shell.ShellExecuteEx方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。