Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.

Windows 7: batch files - run as administrator

24 Apr 2010   #1

Windows 7 Pro
batch files - run as administrator

I am a software developer (dot net). Until recently I did all my work in the XP environment. I developed a utility library that goes into the global assembly cache. In the XP world this was easy.

I write some .bat files that called the gacutil.exe and passed it the appropriate parameters.

gacutil.exe is a command line app, so right-clicking in Explorer and selecting run as administrator does no good.

I use .bat files because the path to gacutil.exe is a mile long, and the path to the library to register is a mile long. Typing the paths by hand every time is very tedious and very error prone.

How can I run the utility with administrator privileges?


My System SpecsSystem Spec
24 Apr 2010   #2


Run from a cmd window launched as admin.

As for the long path... why not create an environment variable for the path, or "set path" ?

(Option Four) Run as Administrator

Attached Thumbnails
batch files - run as administrator-capture.png  
My System SpecsSystem Spec
24 Apr 2010   #3

Windows 7 x64 pro/ Windows 7 x86 Pro/ XP SP3 x86

You could use the "Runas" command at the beginning of your batch file. See this.

Command-line Argument for Admin Rights
My System SpecsSystem Spec

24 Apr 2010   #4

Windows 7 Pro

Great information from both of you!
Thank you very much.
My System SpecsSystem Spec

 batch files - run as administrator

Thread Tools

Similar help and support threads
Thread Forum
UAC - Batch Files just Blink (Do Nothing) when Run-as-Administrator
If the following is true: 1. A batch file resides in a path that is unprotected by windows like C:\Temp or D:\Anything, and, 2. any of the folders in the path, or the name of the batch file, contain the "(" opening parenthesis, and, 3. the batch file is run by clicking/selecting...
System Security
UAC - All Batch Files Fail when Run-as-Administrator
On only one of my Win7 boxes, any attempt to run a batch file with Run-as-Administrator produces the following error dialog. Title: C:\Users\eewiz\Desktop\Test.bat Message: Windows cannot access the specified device path or file. You may not have the appropriate permissions to access the...
System Security
Can no longer run batch files unless as administrator
Windows 7 64-bit Home Premium - Dell 660 w/i5 Intel - 8GB RAM I've been running the same batch files for several years with the same login account. Now, all of a sudden, I have to run them as administrator. My personal account already is an 'administrator' and not a standard user account. ...
General Discussion
How to run a batch , .bat, flle as administrator
I run a batch file from the Windows scheduler and get an error 5, 'access denied'. If i run the batch file as administrator I have access and everything is OK except I must answer the UAC popup. The question is "How can I run the batch file from the scheduler with admin privileges and NOT have to...
General Discussion
How to always run batch file as administrator?
I've made a batch file, but i don't know how to make it to always run as administartor. In .bat's file properties the option "always run as administartor" is grayed out. I have to right click it and then choose "run as administartor" from context menu. But i don't want to do it every time because...
General Discussion

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 19:42.
Twitter Facebook Google+