How to run a batch file in admin mode from a user account?


  1. Posts : 7,906
    Windows 11 Pro 64 bit
       #1

    How to run a batch file in admin mode from a user account?


    I've created batch files to run the following commands to work around a particular problem:

    sc stop cldflt
    sc start cldflt

    The batch files work in my user account if you right click and run them as Administrator.

    There are methods on the forum to run these batch files from a user account as a Task or using the runas command. I can't get these to work. What's the best way to run such batch files from a local account without been prompted for the admin password?
      My Computers


  2. Posts : 17,661
    Windows 10 Pro
       #2

    You must use the /savecred switch, and built-in admin must have a password (default: no password).

    When you run the runas command with /savecred switch first time, built-in admin's password will be asked and saved for that account. In the future, the command is run without password prompt.

    Saved credentials survive restart, which makes it quite a security risk. A restricted user can any time in the future run any command or script, and run any executable with runas.

    Example. Use runas to start elevated Command Prompt:

    runas /user:PC-Name\administrator /savecred cmd

    When run first time, built-in admin password is prompted and saved. When run thereafter, password will not be prompted.

    Kari
      My Computer


  3. Posts : 7,906
    Windows 11 Pro 64 bit
    Thread Starter
       #3

    Kari said:
    You must use the /savecred switch, and built-in admin must have a password (default: no password).

    When you run the runas command with /savecred switch first time, built-in admin's password will be asked and saved for that account. In the future, the command is run without password prompt.

    Saved credentials survive restart, which makes it quite a security risk. A restricted user can any time in the future run any command or script, and run any executable with runas.

    Example. Use runas to start elevated Command Prompt:

    runas /user:PC-Name\administrator /savecred cmd

    When run first time, built-in admin password is prompted and saved. When run thereafter, password will not be prompted.

    Kari
    Thanks. I was using my normal admin account, not the built in one which is why it didn't work.
      My Computers


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 21:22.
Find Us




Windows 10 Forums