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

06 Oct 2013   #11
Layback Bear

Windows 7 Pro. 64/SP-1
 
 

Just a thought.
Do you have a option for Systems to have full permission.


My System SpecsSystem Spec
.
07 Oct 2013   #12
lehnerus2000

W7 Ultimate SP1, LM18 MATE, W10IP VM, W10 Home, #All 64 bit
 
 
Administrators Group != Administrator

Quote   Quote: Originally Posted by blockie View Post
lehnerus2000
...
3. William is an Administrater. But I will change it tomorrow. I also have a everyone user with full privilege.
Human users (i.e. you and me) don't get "full administrator power", even though Windows says we are in the Administrators Group.

The built-in Administrator (i.e. Username: "Administrator") has more power.

On my PC, I'm an administrator and I have received the "You don't have permission to do this. Contact the Administrator" message, when I have been attempting to perform operations.
Though the last time was so long ago that I can't remember what I was trying to do.
My System SpecsSystem Spec
07 Oct 2013   #13
DavidE

Multi-Boot W7_Pro_x64 W8.1_Pro_x64 W10_Pro_x64
 
 

Try changing the user to SYSTEM and see if the task works the way you want.

How to run a batch , .bat, flle as administrator-msesp01.png


My System SpecsSystem Spec
.

12 Oct 2013   #14
blockie

 

Thanks to everyone, But on further investigation of Macrium Reflect, I found that I could put an option in the vmx file that deleted old backups automatically. So this thread becomes not solved but not needed.
My System SpecsSystem Spec
08 Dec 2014   #15
bender123

Windows 7 64bit
 
 

Sorry to resurrect this old thread, but I am dealing with the exact same problem. I have followed each item in the previous posts, but no luck.

I do have one more piece of information, though. When I remove the the argument to run the batch file in Task Scheduler the CMD window will open as Administrator. When I add the argument back it will not open as Administrator.

Can anyone provide insight into this problem?

Much Thanks.
My System SpecsSystem Spec
08 Dec 2014   #16
Tookeri

Windows 7 Pro 32
 
 

Try with this test batch file. It only prints 2 things, if it's running as administrator or not, and the parameters.

Code:
@ECHO OFF
AT > NUL
IF %ERRORLEVEL% EQU 0 (
    ECHO Administrator=YES
) ELSE (
    ECHO Administrator=NO
)
set PARAMS=
SET /A COUNT=0
:CHECKPARAMS
SET /A COUNT+=1
IF [%1]==[] GOTO CONT
IF [%COUNT%]==[1] (
    set PARAMS=%1
) ELSE (
    set PARAMS=%PARAMS% %1
) 
SHIFT
GOTO CHECKPARAMS
:CONT
echo Parameters: %PARAMS%
echo.
pause
When I try to run it from Task Scheduler as admin(Run with highest privileges) and arguments: param1 param2
Administrator=YES
Parameters: param1 param2

Press any key to continue . . .

Also test if the option "Run only when user is logged on" makes a difference.
My System SpecsSystem Spec
09 Dec 2014   #17
Mikkel Birtilid

Windows 8.1 x64-bit, Ubuntu 14.04
 
 

I made a a batch file.
I called it test.bat when I saved it.
Then I create a shortcut of the real test.bat so I have a test.bat - Shortcut
I then Right-click on the test.bat - Shortcut and then I choose properties and then I select advanced in the properties section.
When you have done that there will be a new box you can mark as "Run as administrator".

Try that for starters.
My System SpecsSystem Spec
09 Dec 2014   #18
bender123

Windows 7 64bit
 
 

Mikkel, thanks for the reply. I tried that, but the batch file is to be run unattended so I will not be around to accept the UAC message.


Tookeri,
I can't modify the batch file. Also it looks like it requires user interaction, which needs to be avoided.


Thanks
My System SpecsSystem Spec
09 Dec 2014   #19
Tookeri

Windows 7 Pro 32
 
 

@bender123, I meant you could add a new scheduled task with this test file to see if that works. It works for me so if it works for you too then it's probably an issue with your other batch file or the properties of its scheduled task. This will verify if it's possible from a scheduled task to start a batch file with parameters as administrator.

It doesn't require interaction. The "pause" is there only so you can verify the output, but you could just close the window. It's just a one-time test, nothing you should keep.
The troubleshooting for your issue has to start somewhere and this was my idea for starting point.
My System SpecsSystem Spec
09 Dec 2014   #20
bender123

Windows 7 64bit
 
 

Thanks, Tookeri!

I misunderstood the purpose of your script. I do see a difference in the output when I select/deselect "Run with highest privileges".

I just realized when my Scheduled Task is run it uses taskeng.exe and not cmd.exe. Maybe there is a difference in the way these applications display the privileges?
My System SpecsSystem Spec
Reply

 How to run a batch , .bat, flle as administrator




Thread Tools Search this Thread
Search this Thread:

Advanced Search




Similar help and support threads
Thread Forum
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
Execute Program in Batch File As Administrator (Or Other Solution)
We use a program called TFC.exe (Temp File Cleaner - addpcs.com) to wipe all sorts of temp files off a computer on a monthly basis. The older version was a standalone .exe that users used to execute from a a folder on a server. The newer version is actually installed on each user's PC. If...
General Discussion
shutdown in batch file requires Administrator
Hi all, I've been using GFI Backup 2009 for backups for a while, it does everything I want, and sends email reports after backup is complete. One of its features is to shutdown the computer after a backup, this rarley works, as it wont shutdown if a program is already running, including GFI...
General Discussion
Batch File on USB fails when Ran As Administrator
I am new to this site so please excuse any lack of etiquette I may show. I have recently built a .bat files to perform a large number of configuration changes needed for a Win7 or Win8 workstation to function properly on my network. The .bat file obviously needs to be ran with elevated...
Software
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 20:47.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App