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 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 disable power plan in Windows via GPO and Windows Settings

If you ever find your Windows 10 devices dimming its screen and this act irritates you, I will be describing various ways to prevent Windows from going into standby/sleep after a certain period of inactivity.

Note: Energy Saver Mode feature mainly saves energy when the user is away. Power plans can help you save energy, maximize system performance, or achieve a balance between the two. A balanced power plan offers full performance when you need it and saves power when you are not accessing the PC. It’s the best power plan option chosen by most of the users. To disable the power saving option, follow the steps listed below.

Via Local Group Policy: To Disable this via Group Policy Object (GPO), please follow the following steps as shown below.
– Launch Local Group Policy Editor (gpedit.msc)

– Navigate to Computer Configuration
– Administrative Templates
– System
– Power Management
– Sleep Settings

– Double click on “Allow Standby States (S1-S3) When Sleeping (Plugged In)” and set value do Disabled
– Also, do the same for “Allow Standby States (S1-S3) When Sleeping (On Battery)” and disable it.

Via Group Policy Management: You can also do this in a domain-wide environment. Launch Group Policy Management under Tools as shown below

This will open the Group Policy Management Window as shown below

Click on the domain or Group policy object,
– In my case, I decided to create a GPO before linking it, so I right-click on the Group Policy Object.
– Right-click on the policy and click on Edit as shown below

This will open up the Group Policy Management
– Expand the Computer Configuration and
– Administrative Templates
– System
– Power Management
– Sleep Settings as shown below

– Double click on “Allow Standby States (S1-S3) When Sleeping (Plugged In)” and set value do Disabled
– Also, do the same for “Allow Standby States (S1-S3) When Sleeping (On Battery)” and disable it.

Note: Ensure to link the GPO to the right container (OU) and
– Apply Group Policy Update as sown below

Via the Power Icon on the Taskbar:
– Right-click on the Battery icon from the bottom corner of the taskbar and choose Power Options from the list as shown below

This will open up the Choose or customise a power plan window
– Click on Change plan settings on the balanced power plan as shown below

This will open the window where the Power saver mode can be changed
– Choose Never from the drop-down menu for when plugged-in and on battery.


Via the Control Panel: The Power save mode can be configured never to sleep in the following steps via the control panel.
– Launch the Control Panel
– Click on Hardware

– Click on Power Options.

– Click on Change plan settings on the balanced power plan as shown below

– Choose Never from the drop-down menu for when pluggin and on battery.

– Click on Save changes to ensure the settings take effect.

Via Windows Settings: These steps can be performed via Windows settings in the following ways as shown below.
– Launch the Windows Settings with Win+I keys from your keyboard
– Click on Systems

– Select Battery as seen below

Under the battery notification
– Click on Power and Sleep settings

– Choose Never from the drop-down menu for when plugged and on battery as shown below.

For disabling other windows settings, see https://techdirectarchive.com/2020/01/18/pre-requisites-for-setting-up-a-single-app-kiosk-2/
– If you found other ways to have this done, please share in the comment session.

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.