This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Knowledge Base
- :
- Delete/Disable a Scheduled Task Using an InstallScript Custom Action
Subscribe
- Mark as New
- Mark as Read
- Subscribe
- Printer Friendly Page
Delete/Disable a Scheduled Task Using an InstallScript Custom Action
Delete/Disable a Scheduled Task Using an InstallScript Custom Action
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.
No ratings