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 a batch , .bat, flle as administrator

04 Oct 2013   #1
blockie

 
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 answer the UAC question"?


My System SpecsSystem Spec
.
05 Oct 2013   #2
Brink

64-bit Windows 10 Pro
 
 

Hello William,

You might see if using Option Five in the tutorial below on the .bat file to always have it "Run as administrator" may work when running it with Task Scheduler, but you'll still get the UAC prompt.
Run as Administrator
To not get the UAC prompt, you might see if using the method in the tutorial below to run the .bat set as above may help.
Elevated Program Shortcut without UAC Prompt - Create
Hope this helps. :)
My System SpecsSystem Spec
05 Oct 2013   #3
LMiller7

Windows 7 Pro 64 bit
 
 

Try setting the "Run with highest privileges" checkbox on the general tab of the scheduled tasks properties.
My System SpecsSystem Spec
.

05 Oct 2013   #4
blockie

 

Brink,
I tried option 5 and the RUN AS ADMIN is greyed out and I cannot access it to put a check mark in it. I am the only user of this computer and do have admin privilege.
Bill
My System SpecsSystem Spec
05 Oct 2013   #5
Brink

64-bit Windows 10 Pro
 
 

How does the elevated shortcut from the second tutorial run for you using the .bat as is when creating it?
My System SpecsSystem Spec
06 Oct 2013   #6
blockie

 

Quote   Quote: Originally Posted by Brink View Post
How does the elevated shortcut from the second tutorial run for you using the .bat as is when creating it?
This is what I am trying to do.
1. Delete excess Macrium image backup files from my external HDD. The oldest ones first. I do this at night when the computer is on but unattended. The files I use to do this are contained in folder MyScripts on the desktop.see attached (capture.jpg)
2. The script in delmacimage.bat file is
"DELOLDER cd/D D:\macrium\images\*.mrimg /Keep:6"
The bat file does, in fact ,deletes the required number of files in the intended folder. When I put it in the schedular is where I get in trouble.
3. Security level is all permissions for user "everyone"


Attached Thumbnails
How to run a batch , .bat, flle as administrator-capture.jpg  
My System SpecsSystem Spec
06 Oct 2013   #7
Brink

64-bit Windows 10 Pro
 
 

Did you check "Run with highest privileges"?
My System SpecsSystem Spec
06 Oct 2013   #8
blockie

 

Yes. see attached (3 files)
The arguments for the Action tab are:
/c start "DELMACIMAGE.bat" "C:\Users\William\Desktop\MyScripts\"DELMACIMAGE.BAT "

The shortcut for this does not work. I don't get any error msg's but it does not delete any files either. The only thing that happens is the desktop "blinks" when I use the shortcut. Blink means it looks like a cmd window opens for a fraction of a second

DELMACIMAGE.BAT does delete the excess files. The cmd window opens and the action (deletion of files) can be seen.
The new shortcut just "blinks".


Attached Images
How to run a batch , .bat, flle as administrator-capture.jpg How to run a batch , .bat, flle as administrator-capture1.jpg How to run a batch , .bat, flle as administrator-capture2.jpg 
My System SpecsSystem Spec
06 Oct 2013   #9
lehnerus2000

W7 Ultimate SP1, LM18.3 MATE, W10 Home, #All 64 bit
 
 

Did you start the Task Scheduler using the "Run as administrator" option (in the context menu)?
How to run a batch , .bat, flle as administrator-task-scheduler-start-menu.png
Did the Task Scheduler ask for your Administrator password when you were finalising the task?

Does it make any difference if you change the user from "William" to "Administrator"?


My System SpecsSystem Spec
06 Oct 2013   #10
blockie

 

lehnerus2000

1. I did as the tutorial said.
2. Yes, I was asked for the password and I put it in.
3. William is an Administrater. But I will change it tomorrow. I also have a everyone user with full privilege.
My System SpecsSystem Spec
Reply

 How to run a batch , .bat, flle 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
How do I make this Batch run as Administrator by default?
I haven't looked back since recently and initially reluctantly upgrade from XP to Windows 7. Just loving it now. But I have a small BATCH file problem. I found and adapted a batch file (see below) to start the VAG parts catalogue program after first resetting the system date but then...
Software
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 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
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. ...
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 18:16.
Twitter Facebook Google+