如何使用提升的AutoHotkey启动非提升程序? (没有任务计划程序)

时间:2015-09-09 14:08:55

标签: windows autohotkey

如何在不使用Windows Task Scheduler的情况下从提升的AutoHotkey实例启动非提升程序?

2 个答案:

答案 0 :(得分:0)

实现此目的的另一种方法是使用RunAs命令。不利的一面是,必须在代码中存储本地密码。

RunAs, [Username], [password here] Run, "C:\Users\Ahmed\AppData\Local\Microsoft\OneDrive\OneDrive.exe" RunAs ;Resets the Run command back to normal

答案 1 :(得分:0)

您可以使用shell为您运行应用程序

The function below is made by Lexikos

  

这是博主发布的一种ingenius方法   BrandonLive。   因为ComObjCreate("Shell.Application")创建了一个进程中   对象,它不能直接使用。而是检索托管桌面的进程的shell object

     

该方法可能需要Explorer作为shell - 支持   自定义外壳对于Lexikos的使用并不重要。该计划是   总是在托管桌面的进程的上下文中执行;   即登录用户。

/*
  ShellRun by Lexikos
    requires: AutoHotkey_L
    license: http://creativecommons.org/publicdomain/zero/1.0/

  Credit for explaining this method goes to BrandonLive:
  http://brandonlive.com/2008/04/27/getting-the-shell-to-run-an-application-for-you-part-2-how/

  Shell.ShellExecute(File [, Arguments, Directory, Operation, Show])
  http://msdn.microsoft.com/en-us/library/windows/desktop/gg537745
*/
ShellRun(prms*)
{
    shellWindows := ComObjCreate("{9BA05972-F6A8-11CF-A442-00A0C90A8F39}")

    desktop := shellWindows.Item(ComObj(19, 8)) ; VT_UI4, SCW_DESKTOP                

    ; Retrieve top-level browser object.
    if ptlb := ComObjQuery(desktop
        , "{4C96BE40-915C-11CF-99D3-00AA004AE837}"  ; SID_STopLevelBrowser
        , "{000214E2-0000-0000-C000-000000000046}") ; IID_IShellBrowser
    {
        ; IShellBrowser.QueryActiveShellView -> IShellView
        if DllCall(NumGet(NumGet(ptlb+0)+15*A_PtrSize), "ptr", ptlb, "ptr*", psv:=0) = 0
        {
            ; Define IID_IDispatch.
            VarSetCapacity(IID_IDispatch, 16)
            NumPut(0x46000000000000C0, NumPut(0x20400, IID_IDispatch, "int64"), "int64")

            ; IShellView.GetItemObject -> IDispatch (object which implements IShellFolderViewDual)
            DllCall(NumGet(NumGet(psv+0)+15*A_PtrSize), "ptr", psv
                , "uint", 0, "ptr", &IID_IDispatch, "ptr*", pdisp:=0)

            ; Get Shell object.
            shell := ComObj(9,pdisp,1).Application

            ; IShellDispatch2.ShellExecute
            shell.ShellExecute(prms*)

            ObjRelease(psv)
        }
        ObjRelease(ptlb)
    }
}

this topic

中可以找到更多方法
相关问题