0

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.

Ken White
  • 123,280
  • 14
  • 225
  • 444
jentker
  • 1
  • 1
  • 3
  • `bash` != `batch`. Bash is a command shell for Linux operating systems, and `batch-file` and `cmd` (and `%windir%` and `Microsoft.NET`) are Windows (which is *not* Linux). Please take care to read the description of tags before using them, and make sure you choose tags that actually are relevant to your question. – Ken White Oct 17 '14 at 17:53
  • possible duplicate of [Run BAT as admin (w/o shortcut)](http://stackoverflow.com/questions/20117227/run-bat-as-admin-w-o-shortcut) – Ken White Oct 17 '14 at 17:54

2 Answers2

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:
Rahul
  • 76,197
  • 13
  • 71
  • 125
0

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.

RBH
  • 572
  • 4
  • 11
  • It must be a script file, this way I know – jentker Oct 17 '14 at 17:50
  • Run the script from the administrator’s command prompt itself. for example : if your script is located at `c:\folder\script.bat` go to that directory `cd c:\folder` and run `script.bat` – RBH Oct 17 '14 at 18:00