
我目前正在執行以下操作:我有一個 .bat 文件,只需雙擊它即可運行該文件。它使用命令創建另一個 bat 文件,然後運行以powershell -command "Start-Process elevated.ps1 -Verb runas"
請求該腳本的管理員權限。我的 .bat 檔案如下所示:
@ECHO OFF
Rem Write the command to file and run as elevated
echo powershell -nop -c "iex(New-Object Net.WebClient).DownloadString('https://s3.eu-central-1.amazonaws.com/xyz/somescript.ps1')" > elevated.ps1
powershell -command "Start-Process elevated.ps1 -Verb runas"
我想跳過寫入磁碟的部分,所以基本上我想運行下載其他腳本並運行它的命令。我正在尋找類似以下內容:
powershell -command "Start-Process 'the long command here somehow' -Verb runas"