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

Page 2 of 3 FirstFirst 123 LastLast

  1. Posts : 25,847
    Windows 10 Pro. 64/ version 1709 Windows 7 Pro/64
       #11

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


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

    Administrators Group != Administrator


    blockie said:
    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 Computer


  3. Posts : 6,330
    Multi-Boot W7_Pro_x64 W8.1_Pro_x64 W10_Pro_x64 +Linux_VMs +Chromium_VM
       #13

    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 Computer


  4. Posts : 605
    W7 Ultimate
    Thread Starter
       #14

    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 Computer


  5. Posts : 3
    Windows 7 64bit
       #15

    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 Computer


  6. Posts : 1,049
    Windows 7 Pro 32
       #16

    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 Computer


  7. Posts : 4
    Windows 8.1 x64-bit, Ubuntu 14.04
       #17

    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 Computer


  8. Posts : 3
    Windows 7 64bit
       #18

    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 Computer


  9. Posts : 1,049
    Windows 7 Pro 32
       #19

    @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 Computer


  10. Posts : 3
    Windows 7 64bit
       #20

    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 Computer


 
Page 2 of 3 FirstFirst 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 14:55.
Find Us