Run Windows Scheduled Task from Command Line

This post is in reference to a question posted in one of the forums. The user wanted to invoke a Windows Scheduled Task from the Command Prompt. In this post I had talked a little about the AT command. Microsoft recommends using schtasks command instead of AT. More details about the schtasks command can be found in this TechNet article.

The schtasks utility has a lot of parameters among which run is the parameter to execute a Scheduled Task. Executing the schtasks command without any parameters will list all the tasks created on a server.

The following command can be used to execute a Scheduled Task from the Command Prompt.

schtasks /run /s \ServerName /TN "TaskName"

The \ServerName parameter is not applicable while executing a Local Scheduled Task. So the command to execute this local task on my computer would be schtasks /run /s \ServerName /TN "TaskName"

3 thoughts on “Run Windows Scheduled Task from Command Line

  1. Pingback: Tweets that mention Run Windows Scheduled Task from Command Line | SQL Server DBA Diaries of Pradeep Adiga -- Topsy.com

  2. Pingback: Something for the Weekend – SQL Server Links 28/01/11 | John Sansom - SQL Server DBA in the UK

  3. Colin Jessop

    As others have mentioned the AT security hole is plugged with Win 2008 but even for older versions MS doesn’t recommend disabling this account as noted below.

    http://support.microsoft.com/kb/932881#appliesto

    The NT AUTHORITY\SYSTEM account
    The NT AUTHORITY\SYSTEM account is also granted a SQL Server login. The NT AUTHORITY\SYSTEM account is provisioned in the SYSADMIN fixed server role. Do not delete this account or remove it from the SYSADMIN fixed server role. The NTAUTHORITY\SYSTEM account is used by Microsoft Update and by Microsoft SMS to apply service packs and hotfixes to a SQL Server 2005 installation. The NTAUTHORITY\SYSTEM account is also used by the SQL Writer Service.

    Also, if SQL Server 2005 is started in single-user mode, any user who has membership in the BUILTIN\Administrators group can connect to SQL Server 2005 as a SQL Server administrator. The user can connect regardless of whether the BUILTIN\Administrators group has been granted a server login that is provisioned in the SYSADMIN fixed server role. This behavior is by design. This behavior is intended to be used for data recovery scenarios.

    For more information about security best practices for SQL Server 2005, see the “Security Considerations for a SQL Server Installation” topic in SQL Server 2005 Books Online.

    Reply

Leave a Reply