Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've just started using Windows 7 and am instantly finding one aspect pretty annoying.

When I open certain files from Windows Explorer / Windows Search results etc then I then cannot save them as it throws up the following message box.

C:\Windows\System32\drivers\etc\hosts
You don’t have permission to save in this location. 
Contact the administrator to obtain permission.

Would you like to save in the My Documents folder instead?

[Yes] [No]

However I can't see any way of opening the file with elevated permissions.

Is the only workflow to first open the application with elevated permissions then open the file?

share|improve this question
1  
have you tried opening the explorer itself with elevated permissions? –  Pulkit Sinha Dec 29 '10 at 11:01
add comment

4 Answers

up vote 2 down vote accepted

When i ran into this issue i worked around it by opening the file, making my modifications, then saving the file to the desktop with the same name and extension. Then i find where its on the system, and drag the modified file from the desktop to the folder it belongs. Hurray MS security.....

share|improve this answer
    
That's a shame I was sure that there would be some straight forward work around that would allow me to continue to use the paradigm for working with files that I'm used to. It seems not then! –  Martin Smith Dec 29 '10 at 17:47
add comment

Yes, you have to start the application with elevated permissions first. What you can do to make things a little easier is drag the file from Windows Explorer and drop it over the elevated window of Notepad (in this case).

share|improve this answer
add comment

As an alternative, first create a textfile called elevate.js containing

// elevate.js -- runs target command line elevated
if (WScript.Arguments.Length >= 1) {
    Application = WScript.Arguments(0);
    Arguments = "";
    for (Index = 1; Index < WScript.Arguments.Length; Index += 1) {
        if (Index > 1) {
            Arguments += " ";
        }
        Arguments += '"' + WScript.Arguments(Index) + '"';
    }
    new ActiveXObject("Shell.Application").ShellExecute(Application, Arguments, "", "runas");
} else {
    WScript.Echo("Usage:");
    WScript.Echo("elevate Application Arguments");
}

create a windows explorer shortcut to an editor using elevate.js, for example import this .reg file:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\shell\elevatevim]
@="Edit with GVim (elevated)"
"HasLUAShield"=""

[HKEY_CLASSES_ROOT\*\shell\elevatevim\command]
@="c:\\windows\\system32\\wscript.exe c:\\bin\\elevate\\elevate.js \"C:\\Program Files (x86)\\Vim\\vim73\\gvim.exe\" \"%L\""

Now you can right click on a file to start an elevated editor.

share|improve this answer
add comment

Open notepad.exe with admin permissions, then do a file-Open, navigate to the hosts file.

Right click on notepad.exe or a shortcut to notepad and select run as administrator.

I don't suggest actually changing permissions on the hosts file or other protected Windows files or folders, that is a bad idea.

share|improve this answer
1  
Yes this is the workflow I give in the question. I'm asking for alternatives. –  Martin Smith Dec 29 '10 at 17:43
    
Only other solution is to enable the hidden admin account and use that, I don't recommend it for every day use though. –  Moab Dec 29 '10 at 23:48
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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