2

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?

1
  • 1
    have you tried opening the explorer itself with elevated permissions? Dec 29, 2010 at 11:01

4 Answers 4

2

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

1
  • 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! Dec 29, 2010 at 17:47
1

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

1

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.

0

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.

2
  • 1
    Yes this is the workflow I give in the question. I'm asking for alternatives. Dec 29, 2010 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, 2010 at 23:48

You must log in to answer this question.

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