VbsCaRunSync() |
This function executes the specified command line and uses the normal shell objects "run()" method (waits for the command to complete).
The function takes these parameters:
The processes return code is returned by this function.
EXAMPLE |
;--- Add file --------------------------------------------------------------- <$Component "Doco" Create="Y" Directory_="INSTALLDIR"> <$File Source="out\doco\makemsi.chm"> <$/Component> ;--- Open file near end of install ------------------------------------------ #data "CaDataExecute" "FileToOpen" "[INSTALLDIR]MakeMsi.CHM" #data <$VbsCa Binary="OpenFile.vbs" DATA=^CaDataExecute^> ;--- INSTALL ------------------------------------------------------------- <$VbsCaEntry "OpenFileNearEndOfInstall"> ;--- Build the command we wish to execute ---------------------------- dim StartCmd : StartCmd = "start """" """ & VbsCaCadGet("FileToOpen") & """" ;--- Execute the command --------------------------------------------- VbsCaRunSync StartCmd, 0, "" ;;Ignore RC <$/VbsCaEntry> <$/VbsCa> <$VbsCaSetup Binary="OpenFile.vbs" Entry="OpenFileNearEndOfInstall" Seq="StartServices-" CONDITION=^<$CONDITION_INSTALL_ONLY>^ DATA=^CaDataExecute^>
EXAMPLE - Needed CMD.EXE /c "Magic" |
Sometimes getting the command line to work is tricky, one of the reasons for this is the inconsistancy in the way windows handles command lines. The following shows how I had to update the command I wanted to run to get it to work (in this case what worked manually on a command line differed to what worked in the scripts - a bit of trial and error was required):
;--- Build and execute the required command line --- dim INSTALLDIR : INSTALLDIR = VbsCaCadGetValidate("INSTALLDIR", "DIR") dim DevConExe : DevConExe = INSTALLDIR & "DevCon.exe" dim FullInfName : FullInfName = INSTALLDIR & InfShortName dim TmpFile : TmpFile = oFS.GetSpecialFolder(TemporaryFolder) & "\" & oFS.GetTempName() dim CmdLineSafeId : CmdLineSafeId = HardwareID '=replace(HardwareID, "&", "^&") dim Cmd : Cmd = """" & DevConExe & """ install """ & FullInfName & """ """ & CmdLineSafeId & """ > """ & TmpFile & """ 2>&1" Cmd = "cmd.exe /c """ & Cmd & """" dim Rc : Rc = VbsCaRunSync(Cmd, 0, TmpFile) ;;RC=0 if OK, RC=1 if OK needs reboot?