I want to run a batch file, which I do via the following:
<CustomAction Id='InstallFilter' FileKey='install' ExeCommand='' Execute='deferred' />
<InstallExecuteSequence>
<Custom Action='InstallFilter' Before='InstallFinalize' />
</InstallExecuteSequence>
This will execute the batch file, but it runs in C:\Windows\System32 (or something like that). I want it to run in the directory that the file is found in. It won’et let me specify a Directory attribute with a FileKey attribute. How can I tell the installer to run out of a specific directory, preferably by the directory ID.
Also, when I try to uninstall my app with script, I get an error message saying “There is a problem with the Windows Installer package. A program required for the install to complete could not be run.” This makes sense, as by the time the script gets run, the files have been removed. The question is:
-
How do I specify that my action should only be run on install, not uninstall?
-
How do I uninstall this current copy?
The installer is running as the TrustedInstaller user (an admin) in elevated mode. By default,
cmd.exeworking folder when elevated isC:\Windows\System32. There’s no way (or at least I don’t know of one) to force the working folder for elevatedcmd.exeto be different. (Consider the security implications of running elevatedcmd -c some.cmdfrom random folder)You script can take the folder it’s located in and change the current folder to it like this:
You can look up the different conditions that will allow you to specify when your custom action needs to execute in @Cheeso answer to his own question how to run custom action on uninstall only. (Don’t want to duplicate that information unnecessarily)
Update: If
NOT INSTALLEDdoesn’t work for you specific scenario, tryNOT REMOVE.