Advertisement

There's no such thing as a stupid question, but they're the easiest to answer.
Login
Search

Advertisement

Search Search
Search for:
Tech Support Guy > > >

Running a batch file as an admin


(!)

Maxamuz's Avatar
Maxamuz Maxamuz is offline
Junior Member with 5 posts.
THREAD STARTER
 
Join Date: Sep 2010
29-Sep-2010, 11:30 AM #1
Running a batch file as an admin
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's Avatar
Computer Specs
Member with 9,028 posts.
 
Join Date: Aug 2007
Location: Oregon, USA
Experience: Intermediate
29-Sep-2010, 12:29 PM #2
Quote:
Originally Posted by Maxamuz View Post
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!
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

BBC, Reader's Digest, PC Magazine, Today Show, Money Magazine
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.


(clock)
THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Similar Threads
Title Thread Starter Forum Replies Last Post
Running batch file in VB6 and logging the results /beginner/ perennialstudent Software Development 0 05-Aug-2010 01:10 AM
Solved: How to write a batch file to amend a registry key?? lpool1 Software Development 18 30-Apr-2010 10:33 AM
Create a batch file to open a certain file in a certain file themusikid Windows 7 2 20-Nov-2009 02:29 AM
Run Batch File once Spacecowboy2005 Windows Server 3 27-Apr-2009 11:34 AM
run a batch file as windows nt service radhika123 Windows XP 5 04-Apr-2008 01:40 AM

WELCOME
You Are Using: Server ID
Trusted Website Back to the Top ↑