Introduction
This article explains the process of deleting or disabling a scheduled task before installing with a new installer using a Custom Action in an InstallScript project.
Instructions
When installing with a new installer, if an existing scheduled task is running, the installer will fail to created a new task. In order to create a scheduled task without any issues, first, we should disable or delete the existing scheduled task running on the target machine.
Please follow the steps below to delete or disable an existing scheduled task.
- Create an Installscript project.
- Add files under the Files and Folders View.
- Go to the InstallScript View under Behavior and Logic.
- Select the setup.rul.
- Select the righthand pane.
- Add the following InstallScript code:
function OnBegin()
STRING szMyPath, szCmdPath, szMyCmd, svProgramData, szMyPath2, szCmdPath2, szMyCmd2;
NUMBER nvBufferSize;
begin
szMyPath2 = "\"" + "for /f %x in ('schtasks /query ^| findstr test') do schtasks /Delete /TN %x /F" + "\"";
szCmdPath2 = WINSYSDIR ^ "cmd.exe";
szMyCmd2 = "/c " + szMyPath2;
MessageBox("szMyPath2=" + szMyPath2, INFORMATION);
MessageBox("szCmdPath2=" + szCmdPath2, INFORMATION);
MessageBox("szMyCmd2=" + szMyCmd2, INFORMATION);
LAAW_SHELLEXECUTEVERB="runas";
LaunchApplication(szCmdPath2, szMyCmd2, "", SW_HIDE, INFINITE, LAAW_OPTION_USE_SHELLEXECUTE | LAAW_OPTION_WAIT);
end;
A working sample project that demonstrates this functionality is attached to this article.
More Information
Click here to access the InstallScript Language Reference.
Related Articles
Access SUPPORTDIR from an InstallScript Custom Action 6Number of Views Create a 64-bit Windows Registry Entry via an InstallScript Custom Action 9Number of Views Implement an InstallScript Custom Action to Detect and Display Message About Whether a Directory Exists 3Number of Views EntryPoint Error when adding InstallScript Custom Action. 3Number of Views Deleting a 64 bit Windows Registry Entry via an InstallScript Custom Action 5Number of Views
Hi, I am Reva - Ask me anything.
No new updates
Thanks for the feedback!
Your feedback has been saved.Rate this response:
Add Additional feedback ( Optional )
Are you sure you want to cancel
the case creation?
Are you sure you want to cancel the case creation?
Are you sure you want to close this case
| Products | Region | Phone Numbers |
|---|---|---|
| FlexNet Operations FlexNet Embedded FlexNet Publisher FlexNet Connect FlexNet Code Insight InstallAnywhere InstallShield |
North America * |
+1 630-332-2513 (toll) +1 877-279-2853 (toll-free in North America) |
| Europe * |
+44 1925 944367 (toll) +44 800 047 8642 (toll-free in Europe) |
|
| Japan * | +81 3-4540-5335 (select option 2) | |
| Australia * |
+61 3 9895 2177 +61 1800 560 603 (toll-free in Australia) |
|
|
Usage Intelligence (formerly
Revulytics) Compliance Intelligence |
Please use the Case Portal to submit your support ticket or reach out to your Revenera contact. | |
Case id: 00001065
Activity: Status change: 2 hours ago