I want to start notepad with elevated privileges to edit C:\Windows\System32\drivers\etc\host. Notmally I would type notepad in the search box, and with the program highlighted hot ctrl-shift-enter, click Yes on the UAC prompt and then open the file. I do this often, so I want a batch file to do it.

I tried the following command:

runas /user:Administrator /savecred notepad.exe path\to\file

But this is not exaclty what I want, as it prompts for the password of the Administrator account. I really want a command to start a program with elevated privileges for the current user account.

I run Windows 7 RC.

Thanks!

link|improve this question

45% accept rate
feedback

2 Answers

up vote 4 down vote accepted

As notepad is a Windows tool, you may not set "Run always as administrator", but there's a trick. Create a symbolic link and open the properties dialog. Under the link properties, select Advanced (bottom right button) and select "Run link as administrator". This should elevate the process.

Edit: I hope this is still the same in Win7 (I tested on Vista)

link|improve this answer
Perhaps you could include the directions to create a symbolic link? I don't think it's something most users would ever find. :) – Joshua Oct 12 '09 at 13:57
I created the symbolic link using mklink. The advanced button is disabled. I turned of UAC instead :p – michielvoo Oct 14 '09 at 22:12
The Advanced button on the Shortcut tab is indeed disabled on my Win7 installation (I'm running 7 Pro x64). However, on the Compatibility tab, there is an option to "Run this program as an administrator" ... so it looks as though things just got moved around between Vista and 7. – David Dec 9 '11 at 16:49
feedback

creating a shortcut to notepad, then going to its properties => Advanced run as administrator works on windows7 64bit.

This is a good solution for me, I was looking for a way to add lines to the hosts. file. This is not ideal, but saves me a lot of time finding the damn thing.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.