1

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 exactly 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.

1
  • Note for others seeing this: the correct way to elevate as your own user from a CLI is through PowerShell (or VBScript): Start-Process -Verb runas notepad.exe or from cmd with shorthand powershell -c start -verb runas notepad.exe. PowerShell's -Verb runas does not require switching users as the standalone runas command does.
    – Bob
    Commented Jul 21, 2015 at 10:45

2 Answers 2

4

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.

I hope this is still the same on Windows 7 (I tested on Windows Vista).

3
  • Perhaps you could include the directions to create a symbolic link? I don't think it's something most users would ever find. :)
    – Joshua
    Commented Oct 12, 2009 at 13:57
  • I created the symbolic link using mklink. The advanced button is disabled. I turned of UAC instead :p Commented Oct 14, 2009 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
    Commented Dec 9, 2011 at 16:49
1

Creating a shortcut to Notepad, and then going to its properties => Advanced run as administrator works on Windows 7 64 bit.

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 it saves me a lot of time finding the damn thing.

1
  • It is usually at C:\WINDOWS\system32\drivers\etc\hosts Commented Jul 21, 2015 at 10:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .