# Running a batch file as an admin



## Maxamuz (Sep 22, 2010)

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!


----------



## TheOutcaste (Aug 8, 2007)

Maxamuz said:


> Now the "*callupdates.bat*" file
> 
> @ECHO OFF
> ECHO INSTALLING YOUR UPDATES
> ...


Your file is calling itself.
Give this format a try:

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


----------

