I have a custom action written in c# that can manage scheduled tasks. The CA uses a ScheduledTasks table and was based on this article. Everything is working very well at the moment, with the exception of one key thing :-)
I'm having trouble utilizing the ExeAction column of this table, which is supposed to represent the full path and name of the EXE the scheduled task is intended to run. When the installer runs, it drops the EXE file in the correct directory and the scheduled task is created; however, the exe action of the task always contains the raw ID of the File specified in my .wix file (for instance, [#fil489D713AB5785D45D8F9A2BC3ACD7847]) instead of the actual file name of the EXE we are installing. An export of the created task looks like this:
<Actions Context="Author">
<Exec>
<Command>[#fil489D713AB5785D45D8F9A2BC3ACD7847]</Command>
</Exec>
</Actions>
Here's the rundown of my CA...
The column definition inside the ScheduledTasks table definition:
<!-- Actions -->
<columnDefinition
name="ExeAction"
length="255"
type="string"
category="formatted"
modularize="property"
nullable="no"
description="The path of the executable to run." />
In the immediate custom action method, scheduled after InstallFiles, I extract the ExeAction column from the row, ultimately storing the values inside CustomActionData instances in the session:
CustomActionData data = new CustomActionData();
CustomActionData details = new CustomActionData();
details["ExeAction"] = row["ExeAction"].ToString();
...
session["CreateScheduledTaskDeferred"] = data.ToString();
In the deferred custom action method, scheduled after the corresponding immediate custom action method, I extract the ExeAction value from the session and pass the values to the ScheduledTasks library that will create the scheduled task:
string exeAction = details["ExeAction"];
task.Actions.Add(new ExecAction(exeAction));
Usage of the scheduled tasks custom action is as follows inside my primary .wix file:
<st:ScheduledTask
Id="stask1F47C88A6951460CBE8973F741521206"
ExeAction="[#fil489D713AB5785D45D8F9A2BC3ACD7847]"
... />
I've tried the following:
- In the deferred custom action, trace the value of the extracted ExeAction. When I do this, the value appears CORRECTLY as the full path and exe name!
- In the deferred custom action, extracted the ExeAction value and then converted it to a byte[] and then back to a new instance of a string stored in convertedExeAction variable. I traced this new convertedExeAction variable and see that it contains the correct full path and exe name; however, when I pass this variable to my scheduled task library the created task still contains the [#fil489D713AB5785D45D8F9A2BC3ACD7847]!
- In order to rule out a problem with the scheduled task library, I instead wrote the contents of the ExeAction value to a random file inside the deferred custom action method. The output contained [#fil489D713AB5785D45D8F9A2BC3ACD7847].
I'm not really sure what the problem is at this point. I tried to poke through some of the existing wix extensions; however, I couldn't find any where the CA was written in .Net. The XML table definitions of these extensions seemed to utilize the same modularize="property" attribute when specifying columns that can contain properties, which matches what I've done here.
Any suggestions would be greatly appreciated.