Saturday, December 25, 2010

How to Add "Run as Administrator" to Any File Type in Windows 7 or Vista

 

NOTE : This is a registry hack. Do it at your own risk. But backup your registry first, and create a system restore point. If anything goes wrong, just restore from your registry backup or do a system restore.

If you ever try to unzip a file to the Program Files directory in Windows 7 or Vista You are likely to get all sorts of permission denied errors, and generally be unsuccessful. So what to do now to open up the zip file as an administrator? Or going even further, how do you open any file as administrator?

Don’t worry. There’s a simple registry tweak that will let us specify the action to run as administrator for a file type. Though we have to make the tweak manually, its not that difficult.

Manual Registry Tweak

1. Open regedit.

2. Browse to the following key,

3. Substituting “.zip” for the file extension that you are looking for

HKEY_CLASSES_ROOT\.zip

4. take note of the Data value for the “(Default)” item. This tells us which application is registered to handle this file type, and also where we need to go in the registry next.

image

5. (For this example, since the data field in this example says “WinRAR.ZIP” we’ll need to browse down to the following registry key. (again, the find dialog helps here)

HKEY_CLASSES_ROOT\WinRAR.ZIP\shell\open\command

6. copy the shell\open\command section to shell\runas\command. The easiest way to do that is right-click on “command” and then choose Export.

image

7. Now open up the exported registry file in Notepad and change “open” to “runas” where indicated below:

image

8. Double-click on the file to enter the information into the registry. Now you’ll see that the “runas” section is identical to the “open” section:

image

9. And now you can right-click on a file and open it as administrator:

image

In this example we have used WinRAR, but this will work for any other file type or application. We just have to change where you look in the registry.

No comments: