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

Page 1 of 3 123 LastLast

  1. Posts : 605
    W7 Ultimate
       #1

    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 Computer


  2. Posts : 72,050
    64-bit Windows 11 Pro for Workstations
       #2

    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.
    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.
    Hope this helps. :)
      My Computer


  3. Posts : 2,497
    Windows 7 Pro 64 bit
       #3

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


  4. Posts : 605
    W7 Ultimate
    Thread Starter
       #4

    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 Computer


  5. Posts : 72,050
    64-bit Windows 11 Pro for Workstations
       #5

    How does the elevated shortcut from the second tutorial run for you using the .bat as is when creating it?
      My Computer


  6. Posts : 605
    W7 Ultimate
    Thread Starter
       #6

    Brink said:
    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 Attached Thumbnails How to run a batch , .bat, flle as administrator-capture.jpg  
    Last edited by blockie; 06 Oct 2013 at 17:35. Reason: spelliing
      My Computer


  7. Posts : 72,050
    64-bit Windows 11 Pro for Workstations
       #7

    Did you check "Run with highest privileges"?
      My Computer


  8. Posts : 605
    W7 Ultimate
    Thread Starter
       #8

    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 Thumbnails Attached Thumbnails 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 Computer


  9. Posts : 4,049
    W7 Ultimate SP1, LM19.2 MATE, W10 Home 1703, W10 Pro 1703 VM, #All 64 bit
       #9

    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 Computer


  10. Posts : 605
    W7 Ultimate
    Thread Starter
       #10

    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 Computer


 
Page 1 of 3 123 LastLast

  Related Discussions
Our Sites
Site Links
About 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 01:15.
Find Us