innosetup卸载软件后,删除定时任务schedule task

代码如下:

//innosetup自带的方法,当卸载软件时,根据卸载的状态改变时而触发
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
var
     ResultCode: Integer;//函数参数,结果码
     RemoveParams: String;//移除定时任务的参数

begin
      //usPostUninstall是innosetup定义的状态,usPostUninstall代表卸载完成后
      if(CurUninstallStep = usPostUninstall) then
      begin
            //ScheduleTashName是所要删除的任务名
            RemoveParams:= '/delete /tn "ScheduleTaskName"';
            //Exec()是打开cmd,schtasks是系统自带的schtasks.exe程序
            Exec('schtasks', RemoveParams, '', SW_HIDE, ewWaitUntilTerminated, ResultCode );
      end;
end;
View Code

思路是:

    通过在pascal代码中调用系统的 schtasks.exe程序,来删除定时任务

原文地址:https://www.cnblogs.com/tommy-huang/p/4578928.html