简体   繁体   中英

Run a powershell script in batch file as administrator

I have a powershell script. To run this sript, I have written a batch file.
Here is code of batch file:

:: psscript.bat
set psscript='%CD%\Hotfix-Automation-Installer.ps1'

echo Running PowerShell Script: %psscript%
%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe ^&%psscript% %*

When I double-click on batch file, I want my script Hotfix-Automation-Installer.ps1 to be run as an administrator.
How I can run this script as administrator?

Read Matt's article on this link:
How can I auto-elevate my batch file, so that it requests from UAC administrator rights if required?

He has given complete script to elevate from current session to administrator session. Quiet helpful.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM