Admin privileges in batch script


  1. Posts : 136
    Windows 7
       #1

    Admin privileges in batch script


    Hallo,

    I wrote a Script that uninstalls an application, move some files and install an Application.
    The Script is working if I start it as Admin (right click - run as Admin ...).
    Everything works fine.

    But I want to have it working without the "run as".
    The script is only used in a separated Test system,
    so there is no problem if the Admin user name and password is in the script.
    (also link wouldn't work, should also work if it moves to another station within the test domain)

    Is there a way to manage that?
      My Computer


  2. Posts : 934
    Windows 8.1 ; Windows 7 x86 (Dec2008-Jan2013)
       #2

    Batch command runas with a standard trick
    echo password | runas
    it is NOT going to work, because the password should be entered manually.

    If you do not mind clicking Yes in UAC window you can use Elevate.exe
    With it you won't need writing password anywhere
    "C:\yourFOLDER\elevate.exe" "C:\yourScriptFOLDER\yourScript.bat"
    would be enough to start script with admin privileges (still need to click YES on UAC window).
      My Computer


  3. Posts : 136
    Windows 7
    Thread Starter
       #3

    The goal would be that no user have to enter (password) or click anything(UAC).
    So that the batch can be executed remote or time triggered without any further interaction.

    Batch command runas with a standard trick
    echo password | runas
    it is NOT going to work, because the password should be entered manually.
    Would be fine if something like this would work.
      My Computer


  4. Posts : 934
    Windows 8.1 ; Windows 7 x86 (Dec2008-Jan2013)
       #4

    Using PsExec utility by Sysinternals/Microsoft you can start programs over network, you can specify user, password and even start programs as a System account.
      My Computer


  5. Posts : 136
    Windows 7
    Thread Starter
       #5

    Neutron16 said:
    Using PsExec utility by Sysinternals/Microsoft you can start programs over network, you can specify user, password and even start programs as a System account.
    Yes, but if I can not pase the privileges this way?
    Thats the Problem.
      My Computer


  6. Posts : 934
    Windows 8.1 ; Windows 7 x86 (Dec2008-Jan2013)
       #6

    MPREv said:
    Yes, but if I can not pase the privileges this way?<br />
    Thats the Problem.
    What do you mean? Can you please be more descriptive about problem with privileges?
      My Computer


  7. Posts : 136
    Windows 7
    Thread Starter
       #7

    Neutron16 said:
    MPREv said:
    Yes, but if I can not pase the privileges this way?<br />
    Thats the Problem.
    What do you mean? Can you please be more descriptive about problem with privileges?
    This would work if I start it remote via PsExec.
    But if this is not possible ...

    For Example if a user should start it, another program, time triggered.
      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 23:39.
Find Us