How to create a shortcut to launch an App with admin privileges from the cmd-line?

后端 未结 4 638
死守一世寂寞
死守一世寂寞 2021-01-02 06:19

I have an installer (Inno-Setup) that installs my application to a path defined by the user. At the end of the install routine i want to create a shortcut that starts the ap

4条回答
  •  天涯浪人
    2021-01-02 06:46

    You can add a registry-key that tells windows to execute your program as admin:

    Under HKCU\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers, just add a key(REG_SZ) with the value RUNASADMIN. When you launch your exe, you will be prompted for admin-access.

    With that, you can simply create a normal shortcut to your executable like you would do it with Inno-Setup.

    If you want to do so via a cmd or a batch-file, you can use the following command:

    reg add "HKCU\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v "" /t REG_SZ /d RUNASADMIN
    

提交回复
热议问题