MAKEMSI quickly and reliably creates MSI files in a non-programmatic way
Have your say! Join the MAKEMSI discussion list or view archive! Suggest improvements. No question too simple or too complex.
[Bottom][Contents][Prev]: VbsCaRaiseError()[Next]: Building or Updating MSIs
Have your say! Join the MAKEMSI discussion list or view archive! Suggest improvements. No question too simple or too complex.
\->Source Code->VBSCRIPT->Custom Action Functions->VbsCaRunSync()

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:

  1. The command line.

  2. The run type (as per ".run()" method: 0=hidden).

  3. There are three options as follows:

    1. 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.

    2. 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).

    3. 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.

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?


Microsoft awarded me an MVP (Most Valuable Professional award) in 2004, 2005, 2006, 2007, 2008 & 2009 for the Windows SDK (Windows Installer) area.Please email me any feedback, additional information or corrections.
See this page online (look for updates)

[Top][Contents][Prev]: VbsCaRaiseError()[Next]: Building or Updating MSIs


MAKEMSI© is (C)opyright Dennis Bareis 2003-2008 (All rights reserved).
Friday October 13 2017 at 2:08pm
Visit MAKEMSI's Home Page
Microsoft awarded me an MVP (Most Valuable Professional award) in 2004, 2005, 2006, 2007, 2008 & 2009 for the Windows SDK (Windows Installer) area.