How run file .bat as admin

2019-09-17 06:56发布

问题:

I have question how run file .bat as admin? How run cmd as admin in file bat?

I must run command on cmd: %windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -px "MyKey" c:\key.xml -pri

Please help and have any tips or any good material.

回答1:

Use RUNAS command for this purpose like below. See help using runas /? in command prompt

runas /user:administrator "%windir%\Microsoft.NET\Framework\v2.0.5
0727\aspnet_regiis.exe -px "MyKey" d:\key.xml -pri"

Enter the password for administrator:


回答2:

open start menu by pressing windows key type cmd right click cmd and select Run as administrator this will open the command prompt in administrator mode and then you can run your command as an administrator.