1

Is it possible to just run a single command as admin without actually opening a window as admin ?

1 Answers1

0

Is it possible to just run a single command as admin without actually opening a window as admin ?

You can run a command from a standard user account. But when / if the command requires admin credentials to run, it will pop up a sub-window to obtain the admin userid and password.

You can also run a command from the Start Menu. Press Start and type the command. That works.

But you will still be challenged for Admin Userid and Password.

That is the way Windows works in this situation.

So what I have described is not opening an admin window to run a command, but rather to run the command and satisfy the request for admin user id and password.

Scheduled tasks can store the admin credentials and so can run to a schedule without further asking for credentials but that did not seem to be the case here.

So no matter which method above, you do have to supply admin userid and password to run an admin command.

John
  • 46,167
  • 4
  • 33
  • 54
  • I guess what I'm asking is if there's an equivalent, or close to an equivalent as sudo. But you kinda cleared that up. Still, though, there's commands that just say I don't have the permission to do it instead of popping up with the "Do you want to allow this app to make changes{blah blah blah}". EDIT: rephrasing the question with `sudo` gave me an idea for what to look for and it looks like `runas /noprofile /user:Administrator` is as close as I'll get. – alex Provencher Jan 16 '22 at 03:28
  • "runas" is a command line way. So is Start and Type command as I note. So you can get to a single line. But you cannot avoid permissions. Even "sudo" (I am posting in Linux here) asks for credentials. that you must supply. – John Jan 16 '22 at 12:07
  • Yes, I know. Linux is my area of specialty. I was just looking for something similar to `sudo` so I wouldn't actually have to open a new Powershell windows as admin. I know I will still get the pop-up asking permission. There is a way to avoid it, however, by adding something to the registry. But `runas` does what I was looking for just fine. – alex Provencher Jan 17 '22 at 01:19
  • I am not aware of any simple registry entry that can bypass Admin Credentials (otherwise Windows would not be at all secure). – John Jan 17 '22 at 01:20
  • I found [this](https://superuser.com/questions/42537/is-there-any-sudo-command-for-windows#467311) and [this](https://superuser.com/questions/453409/how-can-i-always-run-the-command-prompt-as-administrator). The first one looks like it'd work fine but I haven't tried it yet. – alex Provencher Jan 17 '22 at 01:32
  • Registry hacking in modern Windows can cause issues down the road which can cause heavy duty repairs. I do not recommend this when answering a credential request is so easy. Up to you of course but not what I would do. – John Jan 17 '22 at 01:50
  • No, I'm not going to. Like I said, just having a command similar to `sudo` is all I was looking for. I don't mind having to confirm, just didn't want to have to open a whole new shell to run SU commands. – alex Provencher Jan 17 '22 at 03:08