Windows – Command to run an application with Administrator privileges, but NOT AS administrator (prompt with UAC)

batchuacwindows 7

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.

Best Answer

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