0
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)?
1
Runas
is a single word. – Ƭᴇcʜιᴇ007 – 2012-06-02T18:25:54.2801First 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 hitEnter
when it prompt for password. Then you can runnet user ABhi*
. – avirk – 2012-06-02T18:49:53.643@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 – 2012-06-02T19:37:45.627
@barlop tried it and yes its in right format its better to check it on your side. :) – avirk – 2012-06-02T23:55:01.803
And yes I just missed the
>
afterC:\
Its my fault sorry for that but console will not leave it. ;) – avirk – 2012-06-02T23:58:43.047@avirk ah you're right that's weird..sorry.. where did you get the notation of /user:username\administrator ? By the way, all you need is /user:Administrator. – barlop – 2012-06-03T00:15:55.793
1
possible duplicate of How to run a program with admin privilege
– Werner Henze – 2014-01-21T09:31:25.410