Can you tell me what I need to make this batch file run?


  1. Posts : 605
    W7 Ultimate
       #1

    Can you tell me what I need to make this batch file run?


    I run a batch file to do image backups. It will only run if I am in the built- in-admin account. When I saw the command line option I thought I had it made. Because the batch file runs in C:\windows\system32\cmd I figured I was already at an elevated commandprompt so I merely added 'net user administrator /active:yes' as the first line in the batch file. I also got a error 5 when the net user line was used. Can you tell me what I need to make this batch file run? I have it on the scheduler to run while I am sleeping.
    Last edited by Brink; 22 Dec 2010 at 18:20. Reason: moved
      My Computer


  2. Posts : 2,009
    Windows 7 Ultimate x86
       #2

    blockie;Error 5 = Access denied
    The command prompt is not automatically elevated just because it runs in \system32\
    You'd have to call CMD in the search bar, right click and run as Administrator.
    ONLY if it looks like this, it's an elevated command prompt
    Can you tell me what I need to make this batch file run?-capture.jpg

    -DG
      My Computer


  3. Posts : 6,285
    Windows 10 Pro X64
       #3

    Create a link on the Desktop to the batch file.
    Right click on the link and select Properties.
    Click on the Compatibility tab.
    Check Run this program as administrator under Privilege Level.

    If Run this program as administrator is greyed out, that means you have UAC disabled. Try enabling UAC then check the box, then disable UAC again.

    You also don't want
    net user administrator /active:yes as the first line of the batch file. That's a one time command to enable the built in Administrator account and does not need to be run more than once.
      My Computer


  4. Posts : 2,009
    Windows 7 Ultimate x86
       #4

    If you use the scheduler anyways why not give it elevated rights directly from there

    https://www.sevenforums.com/tutorials/11949-elevated-program-shortcut-without-uac-prompt-create-3.html#post114406

    -DG
      My Computer


  5. Posts : 605
    W7 Ultimate
    Thread Starter
       #5

    DG:
    Remember I am running this batch file in the scheduler so it is automatic. Is there a way to add the proper words in the batch file to insure an elevated prompt?
      My Computer


  6. Posts : 2,009
    Windows 7 Ultimate x86
       #6

    Not inside the batch, blockie...you assign that in the scheduler so it gets elevated during runtime.
    Check this thread (esp. #7)

    Task - Create to Run a Program at Startup and Log On

    Don't let yourself get confused. that method of course works also if it's not called at startup. So just take the info from the pic at #7 and modify your task accordingly.
    -DG
      My Computer


  7. Posts : 605
    W7 Ultimate
    Thread Starter
       #7

    Took your advice, Sledgedog, and it worked beutifuilly. I'ver got to pay more attention to check boxes in the future. Thanks.
      My Computer


  8. Posts : 2,009
    Windows 7 Ultimate x86
       #8

    You're very welcome, blockie
    Glad it worked for you
    Thanks for the feedback

    -DG
      My Computer


 

  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 03:05.
Find Us