Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was writing a simple batch file with the following command

net user Abhi *

where Abhi is my username and I am the administrator of my computer. On execution, it prompts for a password and then exits with Access is denied error. I know it requires administrator privileges, but don't know how to do it.

I tried it using:

runas administrator net user abhi *

But it did not work.

How do I run this command successfully (as admin)?

share|improve this question
Runas is a single word. – Ƭᴇcʜιᴇ007 Jun 2 '12 at 18:25
First run the command C:\runas /user:username\administrator cmd after this it will ask for password if you have set any type it and if it gives the error then you can try only hit Enter when it prompt for password. Then you can run net user ABhi*. – avirk Jun 2 '12 at 18:49
@avirk that runas you wrote doesn't look right. Better to try it in the cmd prompt first then you'd see. Besides missing the > after C:\, the way you specified the username looks messed up. See my comment to Kevin's answer, it has a runas command there. – barlop Jun 2 '12 at 19:37
@barlop tried it and yes its in right format its better to check it on your side. :) – avirk Jun 2 '12 at 23:55
possible duplicate of How to run a program with admin privilege – Werner Henze Jan 21 '14 at 9:31

You said this is a batch file. If you want the batch file to be run with admin privileges, you can just right click it and check the "Run as Administrator" box under the compatibility tab. This will make it acquire admin rights every time you run it.

share|improve this answer

If it is Windows 7 type in cmd and use CtrlShiftEnter to get and administrator command prompt then run net user or run your batch from that prompt.

share|improve this answer
but i want to run it from windows GUI, not from cmd prompt – abhi120 Jun 2 '12 at 18:35
@abhi120 don't know what you're talking about. What he suggests will open cmd with administrative privileges and your net user administrator * command will then work. But if you want to use the runas command then it's runas /user:Administrator c:\windows\system32\cmd.exe But you may need to do net user first anyway to give it a password. so do the ctrl-shift-enter thing. – barlop Jun 2 '12 at 19:09
In case this is hard to follow, you can also just search for CMD in the start menu, right click the program, and choose Run as Administrator. – TorpedoBench Mar 27 '14 at 23:28

Before net user Abhi * add this cd c:\windows\system32

look like this

cd c:\windows\system32
net user Abhi *
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .