spartacus
Posts: 408
Score: 41 Joined: 2/4/2004 From: Warrington, United Kingdom Status: offline
|
Seems like a good time to post and article I wrote on this subject some time ago. It is geared towards InstallShield users, but can easily be adapted for WISE &c. Background From time to time it is convenient to create a custom action that calls (say) an executable that is already part of the Operating System but which runs in the COMMAND subsystem. One example might be to call the NET.EXE executable to stop a service (OK, I know it's not a great example as you should be using the ServiceControl table here ) The custom action might, for example, call NET.EXE as follows : C:\Windows\System32\NET.EXE STOP SPOOLER The problem with commands like these is that when the Custom Action executes, a command window usually appears on the screen and, besides generally looking untidy, may cause confusion to the end user during installation. This article outlines a method that can be used to invoke the executable to run under the Windows subsystem and not the Command subsystem and thereby avoids the appearance of the command window. Method The method devised makes use of wixca.dll, a DLL supplied in the WiX toolset. If you don't already have it you can download the full WiX tookit from this link http://sourceforge.net/project/downloading.php?group_id=105970&use_mirror=garr&filename=wix-2.0.5805.0-binaries.zip&85039060 We only need the one DLL from the toolkit, so use WinZip or similar to extract the wixca.dll file from the download. 1) Now establish what the exact command is you wish to run. The command must contain a quoted path to the executable, followed (optionally) by any parameters. For example, if we wish to stop the Print Spooler service, the command would be : "C:\Windows\System32\NET.EXE" STOP SPOOLER 2) In your package, create a property named QtExecCmdLine and set the value of this property to the command line in exactly the format shown above. 3) In InstallShield editor, launch the custom action wizard, Click Next then assign the custom action a name plus (optionally) any comments. In my example I will name the custom action StopSpooler and leave the comments blank 4) Click Next, then in the Type field select "Call a function in a Windows Installer dynamic-link library" and click Next 5) In the source field browse to the wixca.dll file you extracted earlier. In the target field enter CAQuietExec then click Next 6) Leave the Return Processing field as Synchronous(Check Exit Code) and click Next 7) Leave the In-Script Execution as Immediate Execution and Execution Scheduling as "Always Execute" and click Next 8) Leave the Install UI Sequence as <Absent from Sequence> and set the Install Execute Sequence field to the desired position in the sequence (e.g. just before InstallFinalize). Apply any Install Execute conditions you need to (e.g. NOT REMOVE~="ALL") then click Next. 9) Click Finish. Thats all there is to it. When the CA runs, you will no longer see a command box, but with verbose logging enabled you will be able to see any output the command created in the MSI log file - very useful for troubleshooting ! Deferred Mode If you wish to run your command in deferred mode, then at step 2, enter a property name of your own choice to hold the command string and make sure (at Step 3) that your custom action is named the same as the property name you chose. This will then instruct the DLL to use the CustomActionData method to determine the command line it needs to execute. (Dont forget to place the custom action between InstallInitialize and InstallFinalize) Further information can be found at the following link : http://wix.sourceforge.net/manual-wix2/qtexec.htm Regards, Spartacus
< Message edited by spartacus -- 2/4/2009 8:54:02 AM >
_____________________________
La mort ne surprend point le sage Il est toujours prêt à partir.
|