How to create a Run As Administrator shortcut using Powershell

后端 未结 2 904
独厮守ぢ
独厮守ぢ 2020-11-30 09:44

In my PowerShell script, I create a shortcut to a .exe (using something similar to the answer from this question):

$WshShell = New-Object -comObject WScript.         


        
2条回答
  •  生来不讨喜
    2020-11-30 10:41

    You can use the -Elevate true switch for this:

        CreateShortcut -name "myApp" -Target 
        "${env:ProgramFiles}\mApp\myApp.exe" -OutputDirectory 
        "C:\Users\Public\Desktop" -Elevated True
    

提交回复
热议问题