I am struggling to understand why my Scheduled Task is running every installation (using AI v15.6). I have given it a condition to be created only if a property (SCHEDULED_TASK_EXISTS) = "0". I have given this property a default value of 0 in the Properties section of Install Parameters. I have a "Execute Inline Script Code" Custom Action (CheckForScheduledTask) that is in between the "Remove Resources" and "Add Resources" sequences. CheckForScheduledTask runs code from a vbscript to check whether or not the file for the scheduled task exists, and if so it will change the value of the Session.Property("SCHEDULED_TASK_EXISTS") equal to "1".
Code: Select all
Dim WindowsFolder, FSO, CustomActionData, jobfile, jobfile2
WindowsFolder = 0
Set FSO = CreateObject("Scripting.FileSystemObject")
CustomActionData = Session.Property("CustomActionData")
jobfile = FSO.BuildPath(FSO.BuildPath(FSO.GetSpecialFolder(WindowsFolder), "Tasks"), CustomActionData)
jobfile2 = FSO.BuildPath(FSO.BuildPath(FSO.GetSpecialFolder(WindowsFolder), "System32\Tasks"), CustomActionData)
if (FSO.FileExists(jobfile) Or FSO.FileExists(jobfile2)) then
Session.Property("SCHEDULED_TASK_EXISTS") = "1"
end if
I am seeing in the MSI log that it does find the scheduled task and the session property's value is changed to "1". Despite this, the scheduled task is still being created. I can confirm this by checked the Date Modified timestamp for the file in C:\Windows\System32\Tasks.
What I am failing to understand is if my session property's, SCHEDULED_TASK_EXISTS, value is being changed to "1", why is my scheduled task with a condition of SCHEDULED_TASK_EXISTS = "0" created?
Any insight or suggestions would be greatly appreciated. Thank you.
FOLLOW US
Get the latest news in Application Packaging