Forum Discussion

tom2025's avatar
tom2025
Copper Contributor
Mar 13, 2025

schtasks help

Hello,

I would like to create the following Scheduled Task via script:

schtasks /Create /RU User /RP Password /SC ONLOGON /TN “Task” /TR “C:\Temp\Programm.exe” /RL HIGHEST /DELAY 0001:00


2 questions:


1) Which switch do I need so that afterwards, under Properties, General, “Only execute if the user is logged on” is checked?

Now the task is created with “Execute regardless of user login”.


2) Which switch can I use to ensure that, for example, Repeat: every hour - for the duration of: 1 day, is entered (Properties, Trigger).

I have already used it with the switch /RI, but the error is displayed on execution, does not work with /SC ONLOGON and is also in the help !??

But if I go to the settings, I can change this manually.....

2 Replies

  • JudeHartley's avatar
    JudeHartley
    Iron Contributor

    For executing only if the user is logged on: Use /IT. For repeating every hour: Use /SC HOURLY with /RI, but you may consider creating separate tasks for both conditions depending on the desired behavior.

  • JaxonRhodes's avatar
    JaxonRhodes
    Iron Contributor

    Remember to replace "User" and "Password" with the actual username and password when running these commands. Also, creating tasks that run interactively may require administrator privileges, depending on your system settings.

Resources