Solved How to run Batch File as Admin?

AlexRD

New member
Pro User
Local time
11:17 PM
Messages
505
Location
Ponta Porã, MS
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.
 

My Computer

Computer Manufacturer/Model Number
Custom Built
OS
Windows 7 Professional x64
CPU
Intel Core i7 2600k - 3.4 GHz
Motherboard
Asus Maximus IV Z68 - Extreme
Memory
4x4 Ripjaws X79 Series 2133 MHz (9-11-10-28)
Graphics Card(s)
1x eVGA GTX 580 - 3GB Classified
Sound Card
Realtek ALC 889 HD Audio
Monitor(s) Displays
Full HD Philips TV 32"
Screen Resolution
1920x1080
Hard Drives
1x Crucial m4 SSD 512 GB
PSU
800W Coolermaster Silentpro Gold
Case
Sentey - Renegade GS-6200
Cooling
Stock
Keyboard
Logitech K800 Wireless
Mouse
Logitech Performance MX Laser
Internet Speed
10MB Internet Connection
Make a shortcut to the bat?
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Custom Build/Mod
OS
Windows 7 Home Premium x64
CPU
Intel QX9650 Extreme 4.0 GHz
Motherboard
ASUS Rampage Extreme Rev2
Memory
8GB (4x2) Corsair Dominator DDR3
Graphics Card(s)
2x Radeon R390X [8GB]
Sound Card
SupremeFX X-Fi
Monitor(s) Displays
Dell 2408WFP 26" Panel
Screen Resolution
1920x1200
Hard Drives
4x WD 2TB (8TB+ Total)
2x Crucial SSD 128GB (RAID-0)
1x LG Blu-ray read/write
1x Phillips LightScribe DVD read/write
PSU
Corsair HX1000
Case
CoolerMaster - Cosmos S
Cooling
Custom Liquid - 320mm rad w/ 3x 80mm fans, CPU/NB/SB Blocks
Keyboard
Logitech Illuminater Pro
Mouse
Logitech
Internet Speed
Fractional T1 - 125Mbps
Antivirus
ESET Security Suite / Microsoft Security Essentials
Browser
Cyberfox Intel x64
Other Info
OC'd to 5.0GHz @ 44c under full load

My Computer

Computer Manufacturer/Model Number
Custom Built
OS
Windows 7 Professional x64
CPU
Intel Core i7 2600k - 3.4 GHz
Motherboard
Asus Maximus IV Z68 - Extreme
Memory
4x4 Ripjaws X79 Series 2133 MHz (9-11-10-28)
Graphics Card(s)
1x eVGA GTX 580 - 3GB Classified
Sound Card
Realtek ALC 889 HD Audio
Monitor(s) Displays
Full HD Philips TV 32"
Screen Resolution
1920x1080
Hard Drives
1x Crucial m4 SSD 512 GB
PSU
800W Coolermaster Silentpro Gold
Case
Sentey - Renegade GS-6200
Cooling
Stock
Keyboard
Logitech K800 Wireless
Mouse
Logitech Performance MX Laser
Internet Speed
10MB Internet Connection
You could try the 'runas' command from another batch initialy, but not sure if it will pass it on to farcry2 though.

Create an initial batch with something like this inside:
Code:
runas /user:REQUIREDUSERNAME /savecred c:\SECONDBATCH.BAT

with your original batch being SECONDBATCH.BAT and replacing 'REQUIREDUSERNAME' with admin account name.

/savecred will make it ask for admin password on first run only.

like I said, Im not sure because I havn't tried it. :o

EDIT: maybe right-click farcry2.exe and set that to run as admin might help.
 

My Computer

Computer Manufacturer/Model Number
Self Built
OS
XP Pro SP3 x86/Vista SP2 x64/Win7 x64 Triple-boot
CPU
AMD64 X2 AM2 5000+
Motherboard
Asus MSN-X Plus
Memory
Corsair TWX 2Gb (2x1Gb) DDR2 800Mhz
Graphics Card(s)
PCI-X 2.0 Inno3D (NVidia) 9500GT 1Gb DDR2
Sound Card
Onboard Realtec ALC662-GR
Monitor(s) Displays
Relisys 17' CRT (model unknown)
Screen Resolution
1024x768
Hard Drives
750Gb Samsung 7200-3Gb/s 32Mb Cache SATA
PSU
500W
Cooling
Standard AMD CPU Fan, One side, front and rear case fan.
Keyboard
Microsoft Multimedia Keyboard
Mouse
Samsung Optical
Internet Speed
10M
The other option is to simply check the 'Run as Admin' option for the FC2 shortcut. You shouldn't need it but some apps/games require this on first fun, especially under 7.
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Custom Build/Mod
OS
Windows 7 Home Premium x64
CPU
Intel QX9650 Extreme 4.0 GHz
Motherboard
ASUS Rampage Extreme Rev2
Memory
8GB (4x2) Corsair Dominator DDR3
Graphics Card(s)
2x Radeon R390X [8GB]
Sound Card
SupremeFX X-Fi
Monitor(s) Displays
Dell 2408WFP 26" Panel
Screen Resolution
1920x1200
Hard Drives
4x WD 2TB (8TB+ Total)
2x Crucial SSD 128GB (RAID-0)
1x LG Blu-ray read/write
1x Phillips LightScribe DVD read/write
PSU
Corsair HX1000
Case
CoolerMaster - Cosmos S
Cooling
Custom Liquid - 320mm rad w/ 3x 80mm fans, CPU/NB/SB Blocks
Keyboard
Logitech Illuminater Pro
Mouse
Logitech
Internet Speed
Fractional T1 - 125Mbps
Antivirus
ESET Security Suite / Microsoft Security Essentials
Browser
Cyberfox Intel x64
Other Info
OC'd to 5.0GHz @ 44c under full load
I think he wants to use 'start' for the realtime option, the only way of setting priority using the UI is through taskmanager and right-clicking the process, which Windows forgets once you close the app.

Edit: Strange, Just tried the shortcut to a batch and I can set 'run as admin' here on mine.
 

My Computer

Computer Manufacturer/Model Number
Self Built
OS
XP Pro SP3 x86/Vista SP2 x64/Win7 x64 Triple-boot
CPU
AMD64 X2 AM2 5000+
Motherboard
Asus MSN-X Plus
Memory
Corsair TWX 2Gb (2x1Gb) DDR2 800Mhz
Graphics Card(s)
PCI-X 2.0 Inno3D (NVidia) 9500GT 1Gb DDR2
Sound Card
Onboard Realtec ALC662-GR
Monitor(s) Displays
Relisys 17' CRT (model unknown)
Screen Resolution
1024x768
Hard Drives
750Gb Samsung 7200-3Gb/s 32Mb Cache SATA
PSU
500W
Cooling
Standard AMD CPU Fan, One side, front and rear case fan.
Keyboard
Microsoft Multimedia Keyboard
Mouse
Samsung Optical
Internet Speed
10M
AFAIK, a batch file should run under the same permissions by default, as the user account it's being run from.
 

My Computer

Computer Manufacturer/Model Number
Personal Build
OS
Vista Ult 64bit - Windows 7 Ult 7264 64bit
CPU
Intel Core 2 Duo E6750
Motherboard
Asus Commando
Memory
4 G's Crucial Ballistix Tracer
Graphics Card(s)
BFG Nvidia 8800 GTS 340
Sound Card
Creative Sound Blaster X-FI Platinum FATAL1TY
Monitor(s) Displays
2-22" HP W2207 LCD
Screen Resolution
1920 x 1080
Hard Drives
3 x 500G WD Caviar SATA II
PSU
Enermax Noise Taker II 600W
Case
NZXT Lexa Classic (dual doored & windowed)
Cooling
Zalman 9700 CPU cooler - 4 x 120mm, 1 x 90mm fans
Keyboard
Logitech MX 5500
Mouse
Logitech MX Revolution
Internet Speed
Blazing...
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.

All replies have been good, and should work, but there is another workaround that can be used so that Administrator Mode will not be required.

The trick is to remember that "C:\Program Files" and "C:\Program Files (x86)" are protected folders in Vista and Windows 7. Any process that attempts to write to them requires either Administrator or Installer access rights.

You can avoid that altogether by installing games to some other user created folder, such as "C:\Games". In other words, when you install a game, when you get to the "Selectg Destination" part of the installer, change the default path to "C:\Games\Far Cry 2".

This will allow the game to be run from an "unprotected" folder, thus allowing normal user rights. And you will likely also not need a special batch file either.

Good thing I've been installing games to "C:\Games" since as far back as Win 95. I've gotten into the habit long ago...
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Virtual Machine
OS
Windows 7 Professional 32-bit SP1
CPU
AMD A4/A6
Motherboard
Intel Corporation 440BX Desktop Reference Platform
Memory
3.00GB EDO
Graphics Card(s)
VMware SVGA 3D
Sound Card
High Definition Audio Device
Monitor(s) Displays
Generic Non-PnP Monitor on VMware SVGA 3D
Screen Resolution
1440x900
Hard Drives
1 x 60GB VMware Virtual SATA Hard Drive ATA Device
Antivirus
Kaspersky Total Security
better yet, install games to a different partition altogether. It will save you from having to reinstall most of them the next time you reformat/reinstall Windows.

I haven't installed a game on my C: drive in ages. I personally install them on a RAID0 array, occasionally backing up my savegames to an external USB drive.
 

My Computer

Computer Manufacturer/Model Number
Too many to list.
OS
XP, Seven, 2008R2
CPU
AMD, Intel, VIA
Motherboard
Various
Memory
Corsair, Kingston, etc.
Graphics Card(s)
ATI, NVIDIA
Monitor(s) Displays
Samsung
Hard Drives
Maxtor, Western Digital
Keyboard
qwerty
Internet Speed
22 Mb/s @ home, 1 Gb/s @ server
Other Info
All of my systems still run fastest on XP 32-bit for the most part. Win7 is fun to play with, but I still prefer XP for raw speed, security, and functionality.
No, you don't get it.
To change a process to REALTIME, its necessary to run as administrator.
And it will prompt to UAC, but now the thing is:

I can run manually on Uac, but then i would have to right click and run as administrator, always.
I wanted it to be like, everytime i double-click it already run as admin without me having to right-click it.
 

My Computer

Computer Manufacturer/Model Number
Custom Built
OS
Windows 7 Professional x64
CPU
Intel Core i7 2600k - 3.4 GHz
Motherboard
Asus Maximus IV Z68 - Extreme
Memory
4x4 Ripjaws X79 Series 2133 MHz (9-11-10-28)
Graphics Card(s)
1x eVGA GTX 580 - 3GB Classified
Sound Card
Realtek ALC 889 HD Audio
Monitor(s) Displays
Full HD Philips TV 32"
Screen Resolution
1920x1080
Hard Drives
1x Crucial m4 SSD 512 GB
PSU
800W Coolermaster Silentpro Gold
Case
Sentey - Renegade GS-6200
Cooling
Stock
Keyboard
Logitech K800 Wireless
Mouse
Logitech Performance MX Laser
Internet Speed
10MB Internet Connection
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 Computer

Computer Manufacturer/Model Number
Custom Hack job
OS
Windows 7 Ultimate 64 bit
CPU
Intel(R) Core(TM)2 Quad CPU Q8200 @ 2.33GHz
Motherboard
GigaByte EP45-UD3
Memory
8 GB Kingston
Graphics Card(s)
Nvidia GeForce 9600GT
Sound Card
Soundblaster Audigy
Monitor(s) Displays
AOC x2 22"
Hard Drives
2 x Samsung 500GB (RAID)
2 x Samsung 2TB
1 x WD Green 2TB
1 x Seagate 1TB
1 x Samsung 500GB
PSU
Thermaltake QFan 750W
Case
CM Scout Gaming
Cooling
Coolermaster V10
Keyboard
Microsoft Wireless Keyboard 1000
Mouse
Microsoft Wireless Optical 2000
Internet Speed
320
Other Info
Winfast PVR2000CP
LG DVD-RAM DVD/RW/DL Super Multi
Linksys WMP300Nx2 Wireless Adapter
this works...thanks a lot
 

My Computer

Computer Manufacturer/Model Number
Lenovo Y430
OS
Win 7 Ultimate 32bit

My Computer

OS
Windows 7 Pro 64bit
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 Computer

OS
Windows 7 Ultimate 64-bit
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 Computer

OS
Windows 7 Professional x64
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 Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
custom build
OS
Windows 8.1 x64
CPU
Intel i7 4930k @3.6Ghz 6 physical cores
Motherboard
MSI X79A-GD45 Plus
Memory
32 GB @2133 MHz
Graphics Card(s)
Nvidia GeForce 780 Ti Superclocked 3GB
Hard Drives
Samsung SSD 840 EVO 250 GB (Primary),
Western Digital 1TB
Browser
Mozilla Firefox
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!
 
Last edited:

My Computer

Computer type
PC/Desktop
OS
Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
Sir, I've just created an account to thank you.
I've been looking for this.
 

My Computer

Computer type
PC/Desktop
OS
Windows 7 Ultimate x64
Thanks for joining usernamewastake.
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Home made Desktop
OS
Windows 10 Pro. 64/ version 1709 Windows 7 Pro/64
CPU
Intel i7-6800K @ 4.3
Motherboard
ASUS X-99 Deluxe II
Memory
Corsair Platinum 16 gig @2400
Graphics Card(s)
EVGA GTX 1070 OC
Monitor(s) Displays
Asus 27" LED LCD/VE278Q
Screen Resolution
1920-1080 or 1280-720 HDMI
Hard Drives
INTEL SSD 730-240 Gb Sata 3.0/
PSU
EVGA Platium 1200W
Case
Phanteks Luxe Tempered Glass 8 fans/ one radiator
Cooling
XSPC/ Water Cooled CPU
Keyboard
Das 4 Professional
Mouse
Logitech M705/MX Anywhere 2-S
Internet Speed
100 mbits
Antivirus
Microsoft Security Essentials/ Malwarebytes Premium 3.0/ SAS
Browser
I.E. 11 default/Firefox/ ISP Time Warner Cable/Spectrum
Other Info
LG BluRay Burner/
Sound system-KLipsch-THX/
Icy Dock ssd Hot Swap bays.
Back
Top