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: How to run Batch File as Admin?

01 Dec 2009   #11
TimStitt

Windows 7 Ultimate 64 bit
 
 

Quote   Quote: Originally Posted by AlexRD View Post
Quote   Quote: Originally Posted by Captain Zero View Post
Make a shortcut to the bat?
Tried that, but the Run as Admin still greyed.
Right click on the shortcut and select the 'shortcut' tab (not the compatibility tab), then click Advanced. Here you will find ANOTHER Run as Administrator option that is just for shortcuts. :-)


My System SpecsSystem Spec
.
01 Feb 2011   #12
GURVIN1

Win 7 Ultimate 32bit
 
 

this works...thanks a lot
My System SpecsSystem Spec
08 Mar 2011   #13
jagaroth

Windows 7 32bit
 
 

I wrote a bat script example which prompts for admin access and then continues. I hope it helps some... jagaroth: admin access prompt for batch files
My System SpecsSystem Spec
.

26 Oct 2011   #14
coolnezz

Windows 7 Pro 64bit
 
 

Quote   Quote: Originally Posted by TimStitt View Post
Quote   Quote: Originally Posted by AlexRD View Post
Quote   Quote: Originally Posted by Captain Zero View Post
Make a shortcut to the bat?
Tried that, but the Run as Admin still greyed.
Right click on the shortcut and select the 'shortcut' tab (not the compatibility tab), then click Advanced. Here you will find ANOTHER Run as Administrator option that is just for shortcuts. :-)

this one worked. thanks a lot.
My System SpecsSystem Spec
27 Apr 2012   #15
Yoyodude1124

Windows 7 Ultimate 64-bit
 
 

Quote   Quote: Originally Posted by AlexRD View Post
Hello,

I want to know how can i run a Batch File (.bat) as administrator since the Run as Administrator Checkbox in Compatibility tab is gray (can't check)?
This is the Batch File:
@echo off
cd /d "C:\Program Files (x86)\Ubisoft\Far Cry 2\bin"
start /realtime FarCry2.exe

Should i put something like Start as admin /realtime ???

Thanks,
Alex.
Make a shortcut to the .bat, right click, go to properties, in the "Shortcut" tap click on advanced, then you can check off "Run As Administrator". Your Welcome.
My System SpecsSystem Spec
10 May 2012   #16
gagruk

Windows 7 Professional x64
 
 
Just what I had been looking for

After reading this thread I kept going because I didn't want to make a shortcut. I came across a solution that worked well for me and thought I would pass it on. You may put a bit of code at the top of the batch file and it will prompt UAC for admin elevation. The code and explanation of how it works can be found here.

I hope this helps someone as much as it helped me.
My System SpecsSystem Spec
16 Jan 2015   #17
Pro VII

Windows 8.1 x64
 
 

Quote:
After reading this thread I kept going because I didn't want to make a shortcut. I came across a solution that worked well for me and thought I would pass it on. You may put a bit of code at the top of the batch file and it will prompt UAC for admin elevation. The code and explanation of how it works can be found here.

I hope this helps someone as much as it helped me.
@gagruk - Made an account just to thank you bro, saved me tonnes of time searching for this.
My System SpecsSystem Spec
17 Jan 2015   #18
Pyprohly

Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
 
 

Hello all,

I present the following batch snippet. It is a one line-er for prompting a UAC dialog box to the user, within a batch file, should the batch script not already be running with Administrative privileges to begin with. And you heard me correctly: ONE. LINE. SOLUTION!

Excuse my excitement, but any batch scripter would know, this is pretty amazingly compact for what it does:

Code:
net session >NUL 2>&1|| powershell Start-Process '%0' -Verb RunAs&& exit /b|| exit /b
Simply place the above line at the top of your batch script, immediately after "@echo off".

This solution involves no third party tools, no Runas command, no registry lookups/changes, and certainty no temp files. Flawless. It's the real-deal.

Akin to all other techniques found on the Web, this works by making a call to an alternate Windows scripting language that is capable of starting processes with elevated (Administrator) permissions. The reason why the above line of batch script does not require temporary files (and thus only one line in length) is because unlike most other solutions that take advantage of VBScript--which all it's code must be packed into a .vbs file to run--, the solution presented above takes advantage of Windows PowerShell. It is possible to make calls to PowerShell's Cmdlets within batch itself, so no need of generating a temporary script file.


Say "no" to "admin" shortcuts to batch files.
And never disable UAC as a solution!
My System SpecsSystem Spec
08 Jun 2015   #19
usernamewastake

Windows 7 Ultimate x64
 
 

Sir, I've just created an account to thank you.
I've been looking for this.
My System SpecsSystem Spec
08 Jun 2015   #20
Layback Bear

Windows 7 Pro. 64/SP-1
 
 

Thanks for joining usernamewastake.
My System SpecsSystem Spec
Reply

 How to run Batch File as Admin?




Thread Tools




Similar help and support threads
Thread Forum
How to run a batch file at logoff & some batch scripting help please
Hiya, I'd just like to run a simple batch file at logoff to backup some settings. I plan to use Robocopy, which is what i use to more thorough backups. Two questions: 1. How make it run by clicking Start > Shutdown? (i realise i could make a shutdown batch file and run it instead, but i'd...
Backup and Restore
I need admin permission to delete/move file (but I'm both admin/owner)
Hi, I'm new to Windows 7. I'm still trying to master the file permissions.. I need some help and I'd appreciate it if someone could help me out. I have a folder with mp3s (created with my old Windows XP system). I've included this mp3s folder in the "my music" library and then I inspected...
System Security
Launch batch file from the context menu in admin mode
Hi, I found a registry script that creates an option on the windows explorer context menu that allows you to run a batch file. The program that I use within the batch file is producing an access denied error which I dont get if I run the batch file normally. I wondered if this was something to...
General Discussion
Batch File that grabs file names from folder to insert into batch file
Ok I'm totally at a loss on how to word this so I'm just going to write it out the best that I can... :confused: First I have a batch file that I'm writing that will convert mp4 files to mp3 files (I have a lot) for a buddies band using ffmpeg. Here's the code that I'm using: ffmpeg -i...
General Discussion
Admin privileges in batch script
Hallo, I wrote a Script that uninstalls an application, move some files and install an Application. The Script is working if I start it as Admin (right click - run as Admin ...). Everything works fine. But I want to have it working without the "run as". The script is only used in a...
Software
Admin rights for batch
I got a batch script which needs Admin privileges. For example it installs some Programmes or move/copy files to/from System directories. So on Windows 7 (and Vista) I can say "Run as" and I got a Message like "are you sure allowing ... bla" OK/Cancel? But how I can get arround this MSG-Box?...
Software


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 16:10.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App