Windows 7 - Opening files from Windows Explorer with Elevated Permissions?

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?

Martin Smith

Posted 2010-12-29T10:25:56.473

Reputation: 191

1have you tried opening the explorer itself with elevated permissions? – Pulkit Sinha – 2010-12-29T11:01:24.787

Answers

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

russjman

Posted 2010-12-29T10:25:56.473

Reputation: 138

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 – 2010-12-29T17:47:00.647

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

realMarkusSchmidt

Posted 2010-12-29T10:25:56.473

Reputation: 131

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.

wimh

Posted 2010-12-29T10:25:56.473

Reputation: 285

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.

Moab

Posted 2010-12-29T10:25:56.473

Reputation: 54 203

1Yes this is the workflow I give in the question. I'm asking for alternatives. – Martin Smith – 2010-12-29T17:43:42.457

Only other solution is to enable the hidden admin account and use that, I don't recommend it for every day use though. – Moab – 2010-12-29T23:48:12.863