|
Answer» Hi all,
I am new to writing batch files and am currently having a problem running a batch file on a users machine.
The batch file installs an application, but normal users do not have permissions to install applications on their PC. I am unable to change this, but what I thought I could do is run the batch file with an admin ID and Password incorpated so that it would install the application as an Admin, but on the users machine.
Only problem is I have no idea how to do this, and can't find this anywhere on the NET!
Can you guys help, i would be hugely greatful?
MANY thanks
Jon In WinXP (at least) you can use the RunAs command like:
RunAs /user:Admin batch.bat
I looked it up here:http://dostips.cmdtips.com/?p=DtCodeSnips.htm
-p try this : where "prog" is the dos PATH of the program you want to run as admin on a local user with limited rights, save the below code as admin.bat and copy the file to the startup of the user profile or run as a script, you can replace the word "prog" by any of ur desired destinations like c:\notepad.exe or anything you want to run.enjoy ****************** @echo off setlocal SET _Admin_=%COMPUTERNAME%\Administrator set _Group_=Administrators set _Prog_="cmd.exe /k Title *** %* as Admin *** && cd c:\ && color 4F" set _User_=%USERDOMAIN%\%USERNAME%
if "%1"=="" ( runas /u:%_Admin_% "%~s0 %_User_%" if ERRORLEVEL 1 echo. && pause ) else ( echo ADDING user %* to group %_Group_%... net localgroup %_Group_% "%*" /ADD if ERRORLEVEL 1 echo. && pause echo. echo Starting program in new logon session... runas /u:"%*" %_Prog_% if ERRORLEVEL 1 echo. && pause echo. echo Removing user %* from group %_Group_%... net localgroup %_Group_% "%*" /DELETE if ERRORLEVEL 1 echo. && pause ) endlocal 8-)
|