Run a powershell script in batch file as administr

2019-06-28 03:36发布

问题:

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?

回答1:

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.