1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Running a batch file as an admin

Discussion in 'DOS/Other' started by Maxamuz, Sep 29, 2010.

Thread Status:
Not open for further replies.
Advertisement
  1. Maxamuz

    Maxamuz Thread Starter

    Joined:
    Sep 22, 2010
    Messages:
    5
    Here is what im trying to do.

    I wrote a batch file that silently updates Adobe Flash Plugin, Adobe Flash for IE, Adobe Reader and Java.

    Our users do not have admin rights and you need them to run most of the updates.

    I tried to write a batch file that runs the "updates.bat" as a admin using the runas command but having no luck.

    Here are the two batch files Im using.

    First off, the main "updates.bat" file

    @ECHO OFF
    ECHO INSTALLING ADOBE FLASH PLAYER PLUGIN UPDATE
    ECHO.
    start /wait @ runas /user:%computername%\administrator /savecred J:\IT\PCUpdates\flash10mozilla.exe -install
    ECHO.
    ECHO.
    ECHO.
    ECHO COMPLETE!
    ECHO.
    ECHO.
    ECHO.
    CHOICE /C:x /T:x,3 > NUL
    ECHO INSTALLING ADOBE FLASH PLAYER UPDATE FOR INTERNET EXPLORER
    ECHO.
    start /wait J:\IT\PCUpdates\flashie.msi /qb
    ECHO.
    ECHO.
    ECHO.
    ECHO COMPLETE!
    ECHO.
    ECHO.
    ECHO.
    CHOICE /C:x /T:x,3 > NUL
    ECHO INSTALLING ADOBE READER UPDATE
    ECHO.
    start /wait J:\IT\PCUpdates\adobe.exe /sPB
    ECHO.
    ECHO.
    ECHO.
    ECHO COMPLETE!
    ECHO.
    ECHO.
    ECHO.
    CHOICE /C:x /T:x,3 > NUL
    ECHO INSTALLING JAVA UPDATE
    ECHO.
    start /wait J:\IT\PCUpdates\java.exe /qn /passive
    ECHO.
    ECHO.
    ECHO.
    ECHO COMPLETE!
    ECHO.
    ECHO.
    ECHO.
    CHOICE /C:x /T:x,3 > NUL
    exit

    Now the "callupdates.bat" file

    @ECHO OFF
    ECHO INSTALLING YOUR UPDATES
    call runas /user:%computername%\administrator /savecred callupdates.bat

    CHOICE /C:x /T:x,3 > NUL

    _________________________

    Should I put the J:\it\bin before the callupdates.bat , but when I do that, nothing happens.

    I just need to have a batch file call the main batchfile and run it as a admin.

    Thank you for any help!
     
  2. TheOutcaste

    TheOutcaste

    Joined:
    Aug 7, 2007
    Messages:
    9,028
    Your file is calling itself.
    Give this format a try:
    Code:
    @ECHO OFF
    ECHO INSTALLING YOUR UPDATES
    Runas /user:%computername%\administrator /savecred "Cmd /C \"J:\it\bin\updates.bat\""
    CHOICE /C:x /T:x,3 > NUL
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/953182