cmd - How do you execute .exe files as administrator or give a run as admin option within a batch file in command line -
i have medical program requires multiple programs within share server installed. made batch file grab programs 1 one , install them while adding share location in windows network removes network drive. need copy clipboard method how because there no automation in pasting directory images in 1 of install programs.
here have far....
keep in mind every program has run admin not admin cmd
@echo off color 2 echo turn on uac turn off uac reboot press enter pause net use z: \\server01\mdcs\auto_update\_csinstaller echo osdetect install set path=\\server01\mdcs\auto_update\_csinstaller start osdetect.exe pause echo osdetect install attempt 2 set path=\\server01\mdcs\auto_update\_csinstaller start osdetect.exe pause echo copy directory press enter echo echo \\server01\oms\pwimage pause echo not restart after wsetup installs echo wsetup install set path=\\server01\oms\image\pwimage\wsetupdir start wsetup.exe pause echo setup-3d-module install set path=\\server01\oms\image\pwimage\wsetupdir\tools start setup-3d-module.exe pause net use z: \delete
use powershell or vbscript batch elevate privileges (via shellexecute).
note runas verb undocumented (not officially supported).
powershell method
powershell -command (new-object -com 'shell.application').shellexecute('program.exe', '', '', 'runas')
vbscript method
set "vb=%temp%\admin.vbs" > "%vb%" echo set uac = createobject^("shell.application"^) >> "%vb%" echo uac.shellexecute "program.exe", "", "", "runas" if exist "%vb%" "%vb%"
Comments
Post a Comment