SEARCH

How-To Geek

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

Have you ever tried to unzip a file to the Program Files directory in Windows 7 or Vista? You’ll get all sorts of permission denied errors, and generally be unsuccessful. So how do we open up the zipfile as an administrator? For that matter, how do you open any file as administrator?

There’s a simple registry tweak that will let us specify the action to run as administrator for a file type. Unfortunately you’ll have to make the tweak manually, but we’ll walk you through it.

Note: The method explained here is courtesy of jd2066, one of the helpful geeks over on our forum.

Manual Registry Tweak

Open regedit through the start menu search or run box and then browse down to the following key, substituting “.zip” for the file extension that you are looking for. (Note that the find dialog helps here)

HKEY_CLASSES_ROOT\.zip

image

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

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

What we want to do is 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

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

image

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

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

image

This example used WinRAR, but this should work for almost any filetype or application. You’ll just have to change where you look in the registry.

Lowell Heddings, better known online as the How-To Geek, spends all his free time bringing you fresh geekery on a daily basis. You can follow him on if you'd like.

  • Published 03/10/08

Comments (59)

  1. timothy

    Great writeup!

    I just created the keys manually instead of exporting them into a file, and it worked that way perfectly. Thanks!

  2. jd2066

    Creating the keys manually will work too only if the type is “REG_SZ”.
    If the default open key is of type “REG_EXPAND_SZ” you have to do that way with the export or use a registry editor that can create keys with a default value of the type “REG_EXPAND_SZ”.
    Most all Microsoft software uses keys of the type “REG_EXPAND_SZ” for the program path.

  3. Gene Thomas

    I don’t get it. You say, “Have you ever tried to unzip a file to the Program Files directory in Vista? You’ll get all sorts of permission denied errors, and generally be unsuccessful.” But I have never had that problem. Generally, I use 7-zip, but the vista installed wizard works too.

  4. The Geek

    @Gene

    If you have UAC disabled you might not get any errors.

  5. jd2066

    Also I don’t think this tip is needed with the builtin Vista zip utility.
    I think it supports UAC just fine.

  6. jd2066

    One other thing to add, if you use a program like 7-Zip with UAC on in Vista without Administrator access and you don’t get permission denied errors then the write likely got redirected to “C:\Users\[UserName]\AppData\Local\VirtualStore\Program Files” instead of “C:\Program Files”.
    If you are the only user of the computer this doesn’t really matter as Vista will make the files in the VirtualStore folder appear to programs as if they really exist in C:\.
    The problem comes if you want something to appear in “C:\Program Files” for all users.

  7. Ryan

    Very useful – anyone know of annything similar for XP?

  8. vinay

    hello buddy…….is there any registy editing by which i can always run a program as administrator????

  9. jd2066

    There isn’t a registry setting but you can go the properties of a shortcut to a program and on the compatibility tab tell it to “Run As Administrator”.
    That will make it always run as administrator.

  10. Ken

    Thanks, this has been driving me crazy.

    Your instructions where perfect and the solution works great.

  11. Jhony

    Hi…I have a little problem…I have a .bat file I configured to renew my IP but it only works if I run it as an administrator…ok..that’s fine, I can right click-run as administrator…it will work….BUT
    i need it to run AUTOMATICALLY because I always leave my pc on the whole night and after one download I need to renew my ip adress..but i can’t be there (i’m sleeping) :)
    my cuestion is…can i ENABLE the box that says…ALWAYS RUN AS ADMINISTRATOR….????? When I go to properties of the .bat file and then to compabillity in the bottom there is a box that says Always run as administrator but i can’t check it….PLEASE HELP!!!!
    ps: Sorry for my english, I’m from Colombia, 16 years old 6-6-08
    Thank You

  12. nightsurfer

    Great !!!

  13. Luke Davidson

    how do you get the file to notepad and then back to registry editor

  14. Rezmuk87

    right click the notepad file, open with…, regeditor

  15. Dave

    For some reason Vista gives me an “access denied” when I try to open Documents and settings. Right clicking-properties- does not have a “run as admin” selection. I need to get in there to edit some things. I am the administrator but occassionally, when I try to delete an exe file I also get the error “you are not authorized to delete this file”. In most cases this is simply a program I installed and now want to delete. It is not something that shows up in the control panel delete programs. How can I get around this dumb thing that will not let me do as I please on my computer?? I am not tryig to alter any system files.

    Dave

  16. patti

    I need to access some files on another hard drive but it keeps saying, access denied.. I need the files to finish some work.. can you help..

  17. Kevin

    Seriously great tip. ;-)

  18. Joseph

    It’s good, but msn is so messed up for me. When i click run as admin nothing happens, and when i open it up normally data execution closes it. And then when i go to compatability i’m not able to make it run as admin permanetly.

  19. ken

    Brilliant guide!!! thank you so much!

  20. rod

    does not work with win 7

  21. CMasMas

    It works beautifully with Windows 7.

    Someone above asked about ALWAYS RUN AS ADMINISTRATOR:
    Simple, at the “Shell” key level, set the “(Default)” value to “runas”.
    (Default) is assumed to be “Open” if nothing else is set.

    “Visual Studio Solution” files are a good example of when you might want to do this.

  22. Jedi

    OMG!!! you are awesome dude.. Thanks! Brilliant instructions.. 10/10
    It just worked for me!

  23. hoang

    I am error path
    HKEY_LOCAL_MACHINE \ WinRAR.ZIP \ shell \ open \ command

    Please help me

  24. Dumb techy

    I’m trying to export shell\open\command but don’t know where to export it to. Do I just pick a spot, because that really didn’t work for me

  25. Psymon

    I want to do the seeming opposite.

    I have a game that once I set it to run with elevated privileges I now cannot undo this and it always requires the admin password now. This is very annoying. I’ve been able to set that privilege level with other exe files and take it away again but not this one (morrowind of all games).

    I tried giving the under account full privileges in regedit too with no success.

    any ideas?

  26. joseph s romano

    I listen I have as little situation regarding administrator or login has administrator.My other question is how do you use the administrtive tools.Because sometimes I’m opening a page any page and it’s trying to open up and then I get a box that pops open and says that I have to login has administrator.

  27. Paulius

    i’m a bit confused. if i have exported the registry file on a desktop. what do I do after I have finished? do i delete it?

  28. stephen makin

    i have windows 7 and i just followed all the instructions but it still wont let me unzip win.rar from a dvd onto my comp. when i right click the “run as administrator option” isnt there.

  29. Derek Guenther

    I hope posting useful scripts isn’t against the rules here. I got bored and threw a half hour into making a batch file that does the same thing, but in a much more automated fashion, and wanted to share. Keep in mind that you’ll have to run the file as an administrator. Considering that the first thing I used the instructions above for was to run a .bat file as Administrator, this might cause you some trouble – so the directions below assume you have not performed that step and provide a workaround.

    I know this is almost as much work as above, but using a script has three advantages. The biggest advantage is accuracy – you don’t have to worry about making a mistake while editing your registry. The second is fairly large too – the registry is a confusing place and very large, it can take some time to search, meaning this will save you some time. And last but not least, if you need to run some other file type as administrator in the future it’ll be much easier: the batch file is already created and is runable as an administrator, so you can edit the extension in it, save it, and right-click to run as admin.

    Steps to use:
    1) First, create a blank text file somewhere you will easily remember. I recommend the root of the C:\ drive, as it’s easy to find in a command prompt (which is necessary if you haven’t used the directions above for .bat files).
    2) Open the file in Notepad and copy-paste the script below into it (starting with “@echo off” til the end of this comment post).
    3) If aiming for a file extension other than .bat, modify the extension targeted in the third line.
    4) Save the file and close it.
    5) Rename the file to “RunExtAsAdmin.bat”.
    6) Hit the Windows key on your keyboard (or click the Start menu button) and type “cmd” into the search bar. In the list that appears, find “cmd.exe”, right-click it, and tell it to run as Administrator.
    7) Enter the following into the command prompt.
    7a) c:
    7b) cd\
    7c) runextasadmin.bat

    @echo off
    REM Set extension here (without period):
    set ext=bat

    REM Performs the step where you “take note of the Data value for the ‘(Default)’ item”.
    for /f “tokens=1,3* delims= ” %%a in (‘reg query hkcr\.%ext%’) do if “%%a” equ “(Default)” (set prog=%%b)

    REM Performs the step to look up the results of our previous step, the equivalent of exporting the registry key.
    for /f “tokens=1,3* delims= ” %%a in (‘reg query hkcr\%prog%\shell\open\command’) do if “%%a” equ “(Default)” (set com=%%b)

    REM Changes the “open” to “runas” and copies the value found in the last step. The equivalent of modifying and importing the registry key.
    reg add hkcr\%prog%\shell\runas\command /t REG_EXPAND_SZ /d %com%

  30. Br. Bill

    Thanks, man. Very handy.

    People, this tutorial is simple and clean. Take your time and retry, paying close attention to the details.

  31. Derek Guenther

    I’m sorry Bill, but your statement makes me cringe. If you’ve ever had to “retry” editing your registry, I recommend you use the script I posted above. When it comes to the registry you shouldn’t mess around – changes need to be done right the first time, or you may leave yourself with an unbootable machine.

  32. Drew

    It says double-click the file to enter the information. what does that mean/how do i do it?

  33. Janee

    Hello…Geek….If you could please assist me with my problem that would be greatly appreciated. I have a version of Sony Vegas (an av editing program) that needs to run as admin in order to work . However, my account on this computer is not an admin and there’s no way that i can get the admin password and i also cannot download anything…the only thing i can use that are programs are exes….please help me. Thank you.

  34. Derek Guenther

    A minor modification to my batch file script above: I found that if the command line had a space in it, this didn’t perform properly. Here’s the corrected version.

    rem @echo off

    REM Set extension here (without period):
    set ext=ini

    REM Performs the step where you “take note of the Data value for the ‘(Default)’ item”
    for /f “tokens=1,3* delims= ” %%a in (‘reg query hkcr\.%ext%’) do if “%%a” equ “(Default)” (set prog=%%b)

    REM Performs the step to look up the results of our previous step, the equivilant of exporting the registry key
    for /f “tokens=1,2,* delims= ” %%a in (‘reg query hkcr\%prog%\shell\open\command’) do if “%%a” equ “(Default)” (set com=%%c)

    REM Changes the “open” to “runas” and copies the value found in the last step. The equivilant of modifying and importing the registry key
    reg add hkcr\%prog%\shell\runas\command /t REG_EXPAND_SZ /d “%com%”

  35. Derek Guenther

    Grrr… also just noticed that this website replaces single and double-quotes with their “smart” equivilants. That means that if you want to use the script above, you’ll have to paste it into Notepad and replace all of the single and double-quotes.

    Well that sucks. Sorry the script couldn’t be more useful.

  36. blackpoison

    Hi
    I have a prob in Vista, if anyone could pls help me with it.
    I want to run a program but it asks for admin passsowrd which i dont know
    Is there any tweak to reset the admin password or get admin rights to a limited account
    Not able to install any software nor can modify anything since it asks for admin password
    Thanks.

  37. Jeff Midi

    i want my computer is fonction

  38. Jeff Midi

    Hi
    i hAVE A PROBLEN IN MY WINDOWS 7 , IF ANYONE COULD HELP ME WHITH IT
    I WANT TO RUN PROGAM BUT IT ASKS FOR ADMISTRATOR INSTALLER WHICH I DONT KNOW

  39. David Wolf

    Could someone please answer Drew’s question. I have exported the registry entry at HKEY_CLASSES_ROOT\WinRAR.ZIP\shell\open\command to a notepad file on my desktop. I have renamed the “open” to “runas”… So far, so good… Double-click the file to enter the information? The notepad file? Like Dorothy clicking her heels? Could someone please make this make sense?

  40. Derek Guenther

    You should have exported the file as “something.reg”. My guess is that you somehow exported it with a .txt extension.

    So, change your extension to .reg and then play Dorothy.

  41. unluckyko

    same problem as drew and david wolf.
    no derek, its something.reg. where do you “double click”, is the question.

    So, Where do you double click?

  42. Derek Guenther

    When editing this, you either exported the registry information as a Notepad .txt file or a Windows Registry .reg file. Note that these directions (and those above) assume you have changed your options in Windows Explorer to allow extensions to be visible (open Windows Explorer, tap the Alt key on your keyboard, go into Tools > Folder Options, View tab, then take off the checkbox for “Hide extensions for known file types”.

    1) You exported the registry information as a Notepad file with the .txt extension. If you have trouble telling, when you double-click the file it will open in Notepad, allowing you to edit it. Instructions from here: Edit the file to change the “Open” to “RunAs” as described above. Save and exit the file, then rename it to have a .reg extension. Once the extension is changed, double-click it and accept the UAC prompt, it will import the registry keys for you.

    2) You exported the registry information as a Registry file. I believe in this case you would be asking how to edit the file rather than how to import it, as when you double-click it Windows will give you a UAC prompt. However, you can right-click it to edit and change the “Open” to “RunAs” as described above, then save and exit, then double-click the file for it to import the registry keys.

    Of course, I still recommend that if you’re having trouble following his instructions above you should give my batch file a try. However, since this website uses “smart quotes” instead of ”normal quotes” (you can see how the the smart quotes lean towards each other) it makes it difficult to use batch file scripts off this website, so keep in mind you’ll have some editing to do per my previous posts.

  43. Redsoul

    Hey, Does this work with batch files? i cant seem to find the open command in Regedit, Help please?

  44. Redsoul

    Or with an .Exe?

  45. vishal

    when i right click on loader file i didn’t get “run as administrator”
    tell me how it could be.

  46. GerryK

    This did not work for me. I can only go as far as Zip in the tree.
    I have many problems with Windows 7, I have no “shake” or “snap”, I cannot log on to Internet Explorer, I cannot download and use many programs or gadgets. No one seem to know what the problem is. I have Kaspersky 2011, Verizon Internet and this is a Gateway new computer, also a Dell Laptop, 1 year old, that I can get Internet Explorer but not anything else that is “extra” with 7 Home Premium.

    If anyone can help, I would really appreciate it.

    Thank you GK

  47. tyler

    it says windows explorer has stopped working everytime i right click on files. how do i fix this please help!!!

  48. aggi

    doesn’t work. did everything correct but no changes. any ideas why?

  49. Michelle

    If the data says “(value not set)”, what SHOULD it be set to?

  50. Pravin

    Hi,

    I am new users of Window 7 Ultimate, I want to paste One file Under c:/Windows/system32/ Folder But it’s not allow to User (In My system having only one user ).

    Any one help me how to possible this ?

    Thanks
    Pravin

  51. beatriz

    hey i have a little problem with my computer. it doesn’t let me download or change some stuff with out an administrator’s permission but i don’t have other accounts other than the one i am using

  52. Jeff

    If you are having a problem like David Wolf or Drew, and your extension is something.reg, all your missing is right clicking the file and opening it with the regedit, not notepad. I just did it and it’s working now. Hope that helps :)

  53. bubba

    Some of these questions are the scariest I have ever seen!

    If you cannot get this to work, QUIT TRYING and go back to bed (I mean really “what does double-click mean?” — get real). Go find a thinking human being to do it for you. Pay him/her anything required. If you continue to try to do it yourself, eventually we will stop hearing from you since your computer will cease to function altogether.

  54. Richard

    Hi
    Just done this for Notepad & I have ‘Run as administrator’ in the right click menu now but do not have the windows shield icon alongside it?
    How is that enabled?
    Thanks

  55. Travis

    YOU…ARE…GOD!!!!!!

  56. mhaye

    hi! gud day what should i do my loptop is starter7 but ive wanted to have a wallpaper someone told me that window starter7 cannot download some wallpaper at my screen on my wall what should i do??

  57. Alexandre

    A TIP!
    Add a string value “HasLUAShield” inside the runas key to show the icon in the menu.

  58. Lucas - Brazil

    Thanks a lot!! It helps me to run the X-FORCE KeyGen and to install 3D Max on my computer!!

    Att, Lucas

  59. Ebony

    Do you need to extract the files before you run as administer? Because after doing what you’ve said it still won’t let me run the rar file I need to

Get Free Articles in Your Inbox!

Join 134,000 newsletter readers

Email:

Go check your email!