I need to kill a running console app which is running in the background using tskill.exe however when I defive $(env.windir)\system32 I get the error below.
The CustomAction/@Directory attribute's value, 'C:\WINDOWS', is not a legal identifier. Identifiers may contain ASCII characters A-Z, a-z, digits, underscores (_), or periods (.). Every identifier must begin with either a letter or an underscore.
And the CustomAction I wrote to run tskill.exe is:
<CustomAction Id="TaskKill" Impersonate="yes" Return="ignore" Directory="$(env.windir)" ExeCommand='"\system32\tskill.exe" /F /IM MyConsoleApp' TerminalServerAware="yes" Execute="deferred"/>
What is the correct way to achieve this?
EDIT: I realized I was using it the wrong way. Here's what I have now:
<Property Id="TASKKILLFILEPATH"/>
<Property Id="QtExecCmdLine" Value='"[TASKKILLFILEPATH]" /F /IM MyConsoleApp.exe'/>
<CustomAction Id='SetTASKKILLFILEPATH32' Property='TASKKILLFILEPATH' Value='[SystemFolder]taskkill.exe' Return='check' />
<CustomAction Id='SetTASKKILLFILEPATH64' Property='TASKKILLFILEPATH' Value='[System64Folder]taskkill.exe' Return='check' />
<InstallExecuteSequence>
<RemoveExistingProducts Before="InstallInitialize" />
<Custom Action='SetTASKKILLFILEPATH64' Before='AppSearch'>VersionNT64</Custom>
<Custom Action='SetTASKKILLFILEPATH32' Before='AppSearch'>Not VersionNT64</Custom>
</InstallExecuteSequence>
Still doesn't work.
What I want to do is to kill a process (MyConsoleApp.exe) before install or uninstall begins.
What is wrong with the code?