20

Is there anyway to enable administrator access instead of having to right click command prompt and run as administrator?

I tried runas /user:administrator CMD (prompts for password) net user administrator /active:yes (System error 5 has occurred. Access is denied.) runas /user:administrator luaexec.exe -w -f cmd.exe /k

This is on my local machine running windows 8 and have no passwords on any accounts

nhat
  • 333
  • 1
  • 3
  • 7
  • Wait... Do you want to elevate the current `cmd` or open a new, elevated one? – PlasmaPower Mar 30 '14 at 14:58
  • I think there is a **local security policy/directive** that doesn't allow administrator logins nor executions for account with no passwords. Maybe that is your problem? Saddly, I don't know what directive that is, I suppose it should be at `secpol.msc`. If you find it, please, report. – Sopalajo de Arrierez Mar 30 '14 at 15:25
  • 1
    Is this method valid for you? http://superuser.com/questions/728810/how-do-you-open-the-command-prompt-in-windows-7-with-a-shortcut-key/728824#728824 – Sopalajo de Arrierez Mar 30 '14 at 15:27
  • I have used this other method, too, but it is shell programming. You could make a `.cmd` to call it with your desired parameters, if any: http://stackoverflow.com/questions/5944180/how-do-you-run-a-command-as-an-administrator-from-the-windows-shell – Sopalajo de Arrierez Mar 30 '14 at 15:28
  • @Plasma - within the current cmd – nhat Mar 30 '14 at 16:14
  • @nhat That is not possible, see [this](http://superuser.com/questions/129034/elevate-a-running-program-to-administrator-windows-7) superuser question. – PlasmaPower Mar 30 '14 at 16:23
  • 1
    [Is there any 'sudo' command for Windows?](https://superuser.com/q/42537/241386) – phuclv Jun 04 '17 at 15:44
  • Try `gsudo`: https://superuser.com/a/1499989/45898 – Gerardo Grignoli Jan 03 '20 at 12:47

3 Answers3

4

You can't change the permission from a current CMD.exe. You have to restart it. This is a Windows limitation. I use NirCmd with the elevate switch to start tools elevated.

magicandre1981
  • 95,704
  • 28
  • 171
  • 240
0

It is not built in to Windows, but you could use the psexec command from PsTools:

psexec -h cmd
PlasmaPower
  • 212
  • 1
  • 8
  • 2
    How to run this from usual (non-admin) CMD? Is it possible? – Suncatcher Dec 10 '17 at 10:25
  • 1
    No it is not possible. `psexec` installs temporary service with `-h` and it requires admin privileges to do that... It is chick and egg problem. Just use `Ctrl + Shift + Enter` from Windows search results. – gavenkoa Jun 11 '21 at 21:56
0

Try the following.

  1. Locate the command prompt (cmd.exe).
  2. Right click on the file, go to Send To - Desktop (create shortcut). enter image description here
  3. Right click on the file again and go to Properties.
  4. The target field put:

    C:\Windows\System32\runas.exe /noprofile /user:Administrator cmd

  5. Open the shortcut, the following screen will be presented to you. enter image description here
stderr
  • 10,046
  • 2
  • 30
  • 48
  • Unfortunately I'm trying to run a script to update IP addresses and what's preventing the command from executing is the cmd.exe needs to be in admin. It would be time consuming to go to every computer to do this. – nhat Mar 30 '14 at 16:20