How to create, edit and delete a scheduled task via the command prompt (CMD)

– For how to create a scheduled task using task scheduler (GUI), see https://techdirectarchive.com/2020/03/24/how-to-create-a-scheduled-task-on-windows-server-2019/
– For how to create a Scheduled task using Windows Admin Center, see https://techdirectarchive.com/2020/03/26/how-to-create-a-scheduled-task-with-windows-admin-center/

Windows Server and Windows 10 has by default has the Task Scheduler and this enables you to run tasks automatically as a scheduled time. Task schedulers can be used to launch applications, word documents, execute scripts at a scheduled time.

The command prompt can be used to create, edit and delete a scheduled task and below are some flags associated with the executable SCHTASKS.EXE file.

Task Scheduler create options via Command-line: Here are the options allowing to create and customize a scheduled task via the command-line.

/CREATESpecifies that you want to create a new an automated routine.
/SCDefines the schedule for the task. Options available, include MINUTE, HOURLY, DAILY, WEEKLY, MONTHLY, ONCE, ONSTART, ONLOGON, ONIDLE, and ONEVENT.
/Dspecifies the day of the week to execute the task. Options available, include MON, TUE, WED, THU, FRI, SAT, and SUN. If you’re using the MONTHLY option, then you can use 1 – 31 for the days of the month. Also, there’s the wildcard “*” that specifies all day.
/TNSpecifies the task name and location. The “MyTasks\Notepad task” uses the “Notepad task” as the name and stores the task in the “MyTasks” folder. If the folder isn’t available, it’ll be created automatically.
/TRSpecifies the location and the name of the task that you want to run. You can select an app or a custom script.
/STDefines the time to run the task (in 24 hours format).
/QUERYDisplays all the system tasks.
/RUSpecifies the task to run under a specific user account.

Create Scheduled Task: Below are the space to create a scheduled task via the command prompt. Launch the Command Prompt with the Administrator’s right. Below is the command and please modify it to your desired need

Daily: Type the following command to create a daily task

SCHTASKS /CREATE /SC DAILY /TN "FOLDERPATH\TASKNAME" /TR "C:\SOURCE\FOLDER\APP-OR-SCRIPT" /ST HH:MM

Weekly: Type the following command to create a weekly task

SCHTASKS /CREATE /SC WEEKLY /D SUN /TN "FOLDERPATH\TASKNAME" /TR "C:\SOURCE\FOLDER\APP-OR-SCRIPT" /ST HH:MM

Monthly: Type the following command to create a monthly task.

SCHTASKS /CREATE /SC MONTHLY /D 15 /TN "FOLDERPATH\TASKNAME" /TR "C:\SOURCE\FOLDER\APP-OR-SCRIPT" /ST HH:MM


To modify (edit) the Task Scheduler option via the Command: In this guide, we are using the following options to create a scheduled task:

/CHANGESpecifies that you want to edit an existing task
/TNSpecifies the name and location of the task that you want to modify
/STDefines the new time to run the automated routine.

These are just some of the available options. You can learn more about the options to change a scheduled task running the SCHTASKS /CHANGE /? command.

To delete a scheduled task: Here are some commands associated with the command prompt to delete a scheduled task.

/DELETESpecifies that you want to delete an existing task.
/TNSpecifies the name and location of the task that you want to delete

This was tested on Windows 10 and Windows Server 2019. If you need any further assistance, please let me know.

How to create a shortcut for Windows scheduled task

On how to create a scheduled task on Windows Server 2019, see https://techdirectarchive.com/2020/03/24/how-to-create-a-scheduled-task-on-windows-server-2019/

Below are the steps to create a shortcut on a Desktop for a scheduled job.
– Create a desktop shortcut. On how to create a shortcut, see the following link https://techdirectarchive.com/2020/03/08/how-to-create-a-shortcut-in-windows/. On how to make a shortcut available to all users, see https://techdirectarchive.com/2019/05/11/how-to-make-a-desktop-shortcut-available-for-all-users-in-windows-7-and-10/

  • Right-click on the desktop
  • Click on New
  • Click on Shortcut
  • When you create the shortcut, in the “Type the location of the item” field, type the following command and enter the appropriate task name.
schtasks.exe /run /tn "Task Name".

I had to open my task scheduler program in order to get my task name as shown below “WindowsUpdate”.

Note: Task Name needs to be the actual name of the task.
– Click on next as shown below

Type a name for your shortcut and press Finish as shown below

Now the shortcut has been created, If you would like to change the icon, see https://techdirectarchive.com/2020/03/14/how-to-change-a-desktop-icon-shortcut-in-windows-10/

As shown below, the desktop icon as been created. When you double-click on the shortcut, it runs the selected file with administrator permissions, without triggering a UAC prompt.

For a similar shortcut task “how to create a desktop shortcut in Windows 10 to switch User Accounts – Fast user switching (Session Disconnection Utility)“, see https://techdirectarchive.com/2020/03/14/how-to-create-a-desktop-shortcut-in-windows-10-to-switch-user-accounts-fast-user-switching-session-disconnection-utility/

How to create a Windows firewall rule

Windows Firewall filters incoming traffic to help block unwanted network traffic. Optionally, Windows Firewall can also filter outgoing traffic to help limit the risk of malware. Although Windows Firewall’s default settings will work well with components built into Windows, they might prevent other applications from functioning correctly.

Windows Firewall’s default settings can also be significantly improved to provide even stronger protection by requiring authorization or limiting the scope of allowed connections.

You can also create this rule via the Windows Firewall (Windows Defender Firewall and Advanced Security, PowerShell as well.

The firewall windows can be accessed via the following path
– Control Panel
– System and Security
– Windows Defender Firewall

This will open the Windows Firewall “Advanced Settings and Advanced Security” as shown below. In order to create an inbound filter, follow these steps:
Program: A rule that allows or blocks connections for a specific executable file, regardless of the port numbers it might use. You should use the Program rule type whenever possible. The only time it’s not possible to use the Program rule type is when a service does not have its own executable.
Port: A rule that allows or blocks communications for a specific TCP or UDP port number, regardless of the program generating the traffic.
Predefined: A rule that controls connections for a Windows component, such as Active Directory Domain Services, File And Printer Sharing, or Remote Desktop. Typically, Windows enables these rules automatically.
Custom: A rule that can combine program and port information.

In this method, you have got two options
– You can choose to exclude WAC from the firewall or
– Create a firewall rule with for the TCP/IP

I will opt for the option to exclude the program option and select the the

%ProgramFiles%\Windows Admin Center\sme.exe

Click to allow connections to the program as shown below

Select the profile it should apply to. Since this is a test environment, I will select all the profiles as shown below. The firewall profiles are:
Domain: Applies when a computer is connected to its Active Directory domain. Specifically, any time a member computer’s domain controller is accessible, this profile will be applied.
Private: Applies when a computer is connected to a private network location. By default, no networks are considered private—users must specifically mark a network location, such as their home office network, as private.
Public: The default profile applied to all networks when a domain controller is not available. For example, the Public profile is applied when users connect to Wi-Fi hotspots at airports or coffee shops. By default, the Public profile allows outgoing connections but blocks all incoming traffic that is not part of an existing connection.

Enter the firewall name and description of the rule and click on Finish

Note: Further parameters can be configured to permit traffic from certain IP ranges etc. For more information, see https://docs.microsoft.com/en-us/windows/security/threat-protection/windows-firewall/create-an-inbound-port-rule

How to create a scheduled task with Windows Admin Center (WAC)

Windows Admin Center provides a central management platform to remotely administer servers. With WAC, we can remotely configure scheduled tasks on remote servers
– On how to create a scheduled task with the in-built Windows task scheduler, see https://techdirectarchive.com/2020/03/24/how-to-create-a-scheduled-task-on-windows-server-2019/
– On how to create Windows Task Scheduler via the command prompt, see https://techdirectarchive.com/2020/03/31/how-to-create-edit-and-delete-a-scheduled-task-via-the-command-prompt-cmd/

To create a scheduled task on Windows Admin Center,
– Click on the server as shown below

This will open up the Windows Admin Center Server Tools as shown below

Under the server tools, search for the scheduled task as shown below
– Search for Scheduled tasks and click on it

This will open up the Scheduled tasks library as shown above
– Click on create
– Enter the rule name
– Enter a description
– Enter the command “This is the path to your PowerShell script”
– Enter and Arguments and “this is the path to your PowerShell executable”

Use the scroll bar to scroll below and populate the window.
– For the frequency, I will choose monthly
– For Trigger, the following date was selected
– Recur on Month(s); Since this is maintenance is going to be on a monthly basis, I will select all the months as shown below.
– Recur on: Month was selected
– Desired update day(s), I selected 18th after the 2nd Tuesday which is Microsoft Patch Tuesday.

Lastly, enter the following information below
– When running the task, use the following account, I selected the”Built-in”
– Choose a built-in account, here there are three options such as the
– LOCAL SERVICE
– NETWORK SERVICE
– SYSTEM
– Select the “System” account as shown below
– And click on submit.

This will prompt you with a windows as shown below to specify the administrator account that the your server will use in connected to the server. I entered domain user account and password as shown below.

This will validate your credentials and prompt a notification, as shown below that the Scheduled task is currently being created.

To create an exception for Windows Admin Center, see the following link https://techdirectarchive.com/2020/03/26/error-failed-to-create-a-scheduled-task-cannot-perform-the-operation-because-the-runspace-pool-is-not-in-the-open-state/

See how to create a scheduled task via Windows native tool below https://techdirectarchive.com/2020/03/24/how-to-create-a-scheduled-task-on-windows-server-2019/

Now the job as been created as shown below
– Click on the job
– Under the more button as shown below,
– Click on start.

As you can see below, the status of your scheduled task will change.

That is all that needs to be configured. If you have any questions, kindly commend below for help.

Error: Failed to create a scheduled task, cannot perform the operation because the runspace pool is not in the open state

This problem occurs because there is no firewall rule that will allow Windows Admin Center access on the remote server.

To fix this issue, temporarily turn off the firewall on your device.
Note: This act is very UNSAFE

Then try to create your scheduled task. When the scheduled task is created successfully, then you have two methods to setup the firewall.

Method 1: Create Inbound Firewall rule via PowerShell.

New-NetFirewallRule -DisplayName „SmeInbounOpenException“ -Description „Windows Admin Center inbound port exception“ -Localport 6516 -Protocol TCP

Ensure the to run PowerShell with Admin privilege, else it will FAIL 🙂

Method 2: You can also create this rule via the Windows Firewall (Windows Defender Firewall and Advanced Security.

The firewall windows can be accessed via the following path
– Control Panel
– System and Security
– Windows Defender Firewall

This will open the Windows Firewall “Advanced Settings and Advanced Security” as shown below.

In this method, you have got two options

  • You can choose to exclude WAC from the firewall or
  • Create a firewall rule with for the TCP/IP

I will opt to go with the option to exclude the program option and select the the

%ProgramFiles%\Windows Admin Center\sme.exe

Click to allow connections to the program as shown below

Select the profile it should apply to. Since, this is a test enviornment, I will select all the profiles as shown below.

Enter the firewall name and description of the rule and click on Finish

Either of the option you chose, you will and the same end result.

Windows Admin Center Error: Failed to create a scheduled task, there is no disconnected command associated with the runspace

This error below was a result of not having the right path to the PowerShell executable. To fix this issue, enter the full path to the PowerShell executable

In the Argument field in Windows Admin Center, enter the full path as shown below

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe

When this complete path is entered as stated,
– Click on submit to create a scheduled task. The following result will be displayed below.

How to update install, update and uninstall extensions in Windows Admin Center

Windows Admin Center is built as an extensible platform where each connection type and tool is an extension that you can install, uninstall and update individually. You can search for new extensions published by Microsoft and other developers, and install and update them individually without having to update the entire Windows Admin Center installation.

Update Extensions: To update an extension, follow the steps below
– Navigate and select “Extension” under the Gateway
– Click on the extension and
– Finally click on Update as shown below.

Uninstall Extension: You can uninstall any extensions you have previously installed, or even uninstall any tools that were pre-installed as part of the Windows Admin Center installation.

To Uninstall an extension in Windows Admin Center, follow the steps below
– Click on the Installed extension and
– Select the name of the extension and
– Click on uninstall as shown below.

Install Extensions:
Installing from NuGet feed: Windows Admin Center will show extensions available from the specified NuGet feed. By default, Windows Admin Center points to the Microsoft official NuGet feed which hosts extensions published by Microsoft and other developers.

Here are the steps to install extensions on WAC
– Click on Extensions as shown below
– Click on Available extensions
– Click on the extension you wish to install and
– Click on Install.

Other Feeds: Installing extensions from a different feed, Windows Admin Center supports multiple feeds and you can view and manage packages from more than one feed at a time. Any NuGet feed that supports the NuGet V2 APIs or a file share can be added to Windows Admin Center for installing extensions.

  • Click the Settings button in the top-right
  • In the left pane, click Extensions.
  • On the right pane, click the Feeds tab.
  • Click the Add button to add another feed. 
  • Enter the path or URl and
  • Click on Add.