How to add a scheduled task with Inno Setup

后端 未结 2 1700
感动是毒
感动是毒 2020-12-03 07:45

I have a small console application that is installed along my (bigger) application. The setup is created with Inno Setup, which works very nice.

I want Inno Setup to

相关标签:
2条回答
  • 2020-12-03 08:32

    To give a more concrete example than the @TLama's answer:

    For example, to schedule a task to run your application with some parameter every hour, use:

    [Run]
    Filename: "schtasks"; \
        Parameters: "/Create /F /SC HOURLY /TN ""My Task"" /TR ""'{app}\MyProg.exe' par1"""; \
        Flags: runhidden
    

    Note:

    • the double double-quotes around the command-line (and task name) and single quotes around the path to the application;
    • the /F switch to overwrite any existing task with the same name (important for re-installations/upgrades).

    See a full documentation for the schtasks.exe command and the [Run] section.


    When you want to debug a non-working task creation, start the schtasks with the cmd.exe /K (and of course, remove the runhidden flag):

    [Run]
    Filename: "{cmd}"; \
        Parameters: "/K schtasks /F /Create /SC HOURLY /TN ""My Task"" /TR ""'{app}\MyProg.exe' par1"""; 
    

    This way the console window with an error message is preserved.

    See Debugging non-working batch file or command executed from Inno Setup installer.


    For uninstalling, see Delete Task Scheduler task at Uninstall?

    0 讨论(0)
  • 2020-12-03 08:45

    Simply add the task scheduler command line entries to the [Run] section of your script. The entries in that section are executed after the program is successfully installed.

    0 讨论(0)
提交回复
热议问题