27

If I open Win + R window and type notepad, then notepad opens.

How can I open it as admin the same way?

yoozer8
  • 444
  • 1
  • 8
  • 26
Realo33
  • 271
  • 1
  • 3
  • 3

9 Answers9

26

Run Once as Admin

The command syntax you want to use is:

runas /user:<localmachinename>\administrator notepad

NOTE: Designating the machine name is optional. It works like this too:

runas /user:administrator notepad

Substitute administrator for the account name that has admin access. You will need to authenticate using this process.

As @EBGreen suggested in the comments, you can save the credential on the first execution and avoid reentering it on subsequent calls. This option only lasts for the existing logon session:

runas /user:administrator /savecred notepad

Reference:

http://technet.microsoft.com/en-us/library/cc771525.aspx

Always Run As Admin

You can also set it so that all programs run in admin mode. This is typically not recommended as UAC exists for a reason, but if you're so inclined follow the steps here:

Always Run as Administrator

Colyn1337
  • 1,228
  • 9
  • 24
  • 1
    You can add the /savecred flag to not be prompted in the future too. – EBGreen Oct 09 '13 at 19:59
  • @EBGreen how long does that last? How could you cancel it if you needed to during the existing session? I'm curious as that's not a setting I use often. – Colyn1337 Oct 09 '13 at 20:08
  • Actually disregard if you are on W7 (and presumably W8) since it isn't available in those environments. I believe that it lasts during the current session and as far as I know there is no way to tell it to ignore the credentials once you have given them. – EBGreen Oct 09 '13 at 20:15
  • @EBGreen I tested it out on W7 and WS08R2 and it worked. – Colyn1337 Oct 09 '13 at 20:22
  • Cool. I love docs that lie... – EBGreen Oct 09 '13 at 20:22
  • @deed02392 see *Substitute administrator for the account name that has admin access.* in the answer. – Colyn1337 Oct 10 '13 at 14:04
  • 1
    @Colyn1337, **Does not work**. I tried `runas /user:myname cmd` and entered the password in the prompt. However, the command prompt is **still** not elevated! This can be verified by typing `sfc`. – Pacerier Apr 24 '15 at 05:07
24

As far as I know, this task will be started with Admin rights if it is started using WinKey+R when UAC is disabled

enter image description here

Anyway, you can do the same if you press WinKey key, type notepad in the Search field and press Ctrl + Shift + Enter

Nikola Dimitrijevic
  • 4,095
  • 1
  • 18
  • 28
  • 12
    I think it's running all tasks as an Administrator automatically because you've got UAC turned down/off... But +1 for suggesting using the search box & ctrl+shift+enter. :) – Ƭᴇcʜιᴇ007 Oct 09 '13 at 19:27
  • @techie007 If that's what it takes, post as an answer – Canadian Luke Oct 09 '13 at 19:27
  • 2
    @techie007 is right. You only get that option if you've done this: http://superuser.com/questions/431112/always-run-as-administrator – Colyn1337 Oct 09 '13 at 19:27
  • @CanadianLuke I considered it, but the OP doesn't say they want it to _always_ run it as admin. :) – Ƭᴇcʜιᴇ007 Oct 09 '13 at 19:29
  • @NikolaD If I do the same, then it doesn't run with admin privileges. – Realo33 Oct 09 '13 at 19:34
  • @Realo33 Win+R or ctrl+shift+enter version doesn't work for you? Win+R explained techie007... I'm always forgetting that the fact that I'm running my Wins with UAC down, doesn't mean that other people do that :). The second proposal will run notepad as admin – Nikola Dimitrijevic Oct 09 '13 at 19:38
  • @NikolaD Thanks the second one works. +1 for that, but it was not the question. – Realo33 Oct 09 '13 at 19:47
  • @Realo33 Just edited my answer to make things more clear. – Nikola Dimitrijevic Oct 09 '13 at 20:42
  • @Kevin Panko Lets make post looks even more better :):) – Nikola Dimitrijevic Oct 09 '13 at 21:57
  • @NikolaD Unfortunately the domain imgur.com is blocked for me, so I do not see any of the images. That's not your fault though. I'm sure it looks great. – Kevin Panko Oct 09 '13 at 21:59
  • 1
    I use the start menu search box method very often that I've already abandoned the run dialog. I disabled file search for that box to make it fast and now its only purpose is to run programs in start menu and %PATH%. If you can do it so conveniently with the start menu, why would you still need the run dialog? @Realo33 – Alvin Wong Oct 10 '13 at 09:42
  • Using the start menu search box, it's only a few keystrokes: `WinKey`, `cmd`, `Enter`, `Alt`+`Y` – Alvin Wong Oct 10 '13 at 09:46
7

If you don't mind using a third party program, there are several programs named elevate.exe written by different people. These programs work (mostly) like this:

elevate.exe notepad.exe

and then a UAC dialog pops up. Confirm it and your notepad has admin privilege.

Here's a blog post about this: http://www.raymond.cc/blog/trigger-uac-elevation-from-command-line-with-elevate-utility/

Inglis Baderson
  • 561
  • 1
  • 4
  • 13
7

The runas method often suggested has a major problem - it requires the use of a different account (Administrator), with the associated different profile. Administrator also happens to default to disabled. Running as any other standard administrative account actually uses the UAC-restricted token, defeating the purpose.

It is possible to elevate as your current user purely through the command line without third-party tools, though it's a little more complicated. One way is through the PowerShell Start-Process commandlet. The full invocation is:

Start-Process -Verb "runas" notepad.exe

Shortening it, we can get:

start -verb runas notepad.exe

Running it from the command line, or from the Run dialog:

powershell -c start -verb runas notepad.exe

It's also possible to save a script that can be run simply as elevate, like in AgreeOrNot's answer - which, again, doesn't require any third-party tools.

Bob
  • 60,938
  • 25
  • 191
  • 216
5

I have another solution for you.

Press windows key, write down notepad and press ctrl+shift+enter

This will automatically open notepad (or any other programs windows searched for) as admin.

gl,

Refael

Refael
  • 251
  • 1
  • 1
  • 3
    This only works when you type into the box after pressing the windows button. It doesn't work if you press Windows+R then do it (a bug IMO) – Matt Wilko Oct 10 '13 at 13:00
3

This doesn't quite answer your exact question but you can open notepad as admin by doing the following:

  • Press Windows Key
  • Type notepad
  • Press Ctrl+Shift+Enter
Matt Wilko
  • 280
  • 2
  • 5
  • 13
1

There is a work around solution for this in Microsoft forum. copy paste below lines to a notepad and save it as sudo.cmd and place it in the system32 folder

@echo Set objShell = CreateObject("Shell.Application") > %temp%\sudo.tmp.vbs

@echo args = Right("%", (Len("%") - Len("%1"))) >> %temp%\sudo.tmp.vbs

@echo objShell.ShellExecute "%1", args, "", "runas" >> %temp%\sudo.tmp.vbs

@cscript %temp%\sudo.tmp.vbs

Now, take a Run terminal and type sudo notepad

Hope this will help you.

Renju Chandran chingath
  • 1,465
  • 3
  • 12
  • 19
0

my case host file is read-only

and need to remove the checkmark on read-only on properties of my file.

  • right click on your file
  • properties
  • of read-only checkbox marked remove and save and apply then you can save or overwrite it

best regards

saber tabatabaee yazdi
  • 1,603
  • 7
  • 21
  • 29
-1

The Simplest Way I know to do this is to Right Click on the Normal Desktop Shortcut for the program, Choose Properties, Choose compatibility, Click off the "Run This Program as Administrator" then (if you choose) click "Change Settings for All users" This takes care of it and stays that way.

questorfla
  • 37
  • 5