Hi,
The problem you are encountering is probably due to the wrong use of quote characters around file/folder paths.
A better and simpler alternative to using a VBScript Custom Action would be the "
CreateExeProcess" function exported by the "
aicustact.dll".
Supposing that you want to execute the following command (to redirect the output of "pscp.exe", suppressing the console window):
Code: Select all
pscp.exe -pgpfp > "C:\Program Files\out.txt"
you should follow the steps below:
1. Add "pscp.exe" as a Temporary File in the Files and Folders page, under "Windows Volume\Temporary".
2. In the Custom Actions page, add the "
CreateExeProcess" CA as described in the following post:
http://www.advancedinstaller.com/forums ... 3991#13991
3. Set the "Action Data" field to the command you want to execute, in this case:
Code: Select all
"[%ComSpec]" /C "[AI_PSCP.EXE]" -pgpfp > "[ProgramFilesFolder]out.txt"
I shall explain the command used:
a) "[%ComSpec]" is a Formatted value which at install time resolves to the value of the "ComSpec" environment variable (which designated the command interpreter). It is enclosed within quotes because its full path may contain spaces.
The command (
pscp.exe -pgpfp > out.txt) must be invoked through the command interpreter because I/O redirection (used in the example) is available only within the command shell.
The /C switch executes the specified command (within quotes) and then terminates the "cmd.exe" process.
b) The file path containing the redirected output from "pscp.exe" is enclosed within quotes (because file paths usually contain spaces). The command to be executed by "cmd /C" is not necessary to be enclosed within quotes.
4. Set the Execution Properties of the Custom Action to "Synchronous Execution, ignore return code" because the
CreateExeProcess function will return a value based on the exit code of the executed command (in this case "cmd.exe") and that may cause the installation to fail.
5. Set the Execution Options to "Deferred with no impersonation" if the CA performs system changes (as it is the case now, since a file "out.txt" gets created under "Program Files").
You can also select "Immediate execution" if the command you execute does not perform system changes.
6. Set the Execution Condition appropriately, most often it will be:
7. Build and install the package. If you have followed the above steps correctly, a file named "out.txt" should be present under "Program Files", containing the output from the "
pscp.exe -pgpfp" command.
If you encounter any problems, please post the exact commands you want to execute and I shall give you more details.
Hope this helps.
Regards,
Ionut