\
Source Code
VBSCRIPT
Custom Action Functions
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 command line.
- The run type (as per ".run()" method: 0=hidden).
- There are three options as follows:
- Pass a blank string or "?" to cause the output
to be redirected to a temporary file and logged.
To ensure the output can be redirected the command line you
pass is executed via the command processor.
- Pass the name of one or more files which should be dumped after
the command completes.
Use ";" (semi-colon) to separate files.
The filename "?" causes redirection to occur and represents
the redirected output (no redirection takes place if "?" not found).
- Pass the string "!" to execute the command as is.
No redirection or logging of any generated files takes place
The processes return code is returned by this function.
;--- 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?