I use the batch script to create a scheduled task:
schtasks /Create /F /RL highest /SC onlogon /TR "C:\MyFile.exe" /TN "MyDescription"
It perfectly runs my application on every user logon. However, it automatically enables "Stop the task if it runs longer than" option with "3 days". I think it is default behavior.
My application may run on servers and it should not quit after 3 days. How can I modify the batch script so that my application runs infinitely?
thanks to @anon coward's comment, I was able to get this made:
<?xml version="1.0" ?>
<!--
This sample schedules a task to start notepad.exe when after login.
-->
<Task xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
<Date>2022-11-16T00:00:00-00:00</Date>
<Author>It's a me, Mario</Author>
<Version>0.0.1</Version>
<Description>Bowser watch daemon</Description>
</RegistrationInfo>
<Triggers>
<LogonTrigger>
<StartBoundary>2005-10-11T13:21:17-08:00</StartBoundary>
<EndBoundary>2060-01-01T00:00:00-08:00</EndBoundary>
<Enabled>true</Enabled>
<ExecutionTimeLimit>PT0S</ExecutionTimeLimit>
</LogonTrigger>
</Triggers>
<Settings>
<Enabled>true</Enabled>
<AllowStartOnDemand>true</AllowStartOnDemand>
<AllowHardTerminate>true</AllowHardTerminate>
<DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
<StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>
<Hidden>true</Hidden>
<ExecutionTimeLimit>PT0S</ExecutionTimeLimit>
<RunOnlyIfIdle>false</RunOnlyIfIdle>
<IdleSettings>
<StopOnIdleEnd>false</StopOnIdleEnd>
<RestartOnIdle>false</RestartOnIdle>
</IdleSettings>
</Settings>
<Actions>
<Exec>
<Command>notepad.exe</Command>
</Exec>
</Actions>
</Task>
run with:
schtasks /Create /XML <xmlpath> /TN "BowserWatch"