Featured image of post Setting Weekly Restart Interval on Windows System

Setting Weekly Restart Interval on Windows System

This article explains how to set up a scheduled restart in Windows operating systems, detailing steps for automation using Task Scheduler and PowerShell scripts.

In Windows systems, you can use the Task Scheduler to set up regular restarts or shutdowns for your server. This guide will illustrate how to schedule a weekly restart every Saturday at 8 PM. Here are the detailed steps:


Method 1: Using Task Scheduler for Automatic Restart

  1. Open Task Scheduler
    Press Win + S, type Task Scheduler, and hit Enter to open it.

  2. Create a Basic Task

    • Click on “Create Task” in the right-hand actions panel.
    • In the pop-up window, enter a task name (e.g., “Weekly Restart”) and a description (optional). Windows Task
  3. Configure Triggers

    • Navigate to the “Triggers” tab.
    • Click on “New”.
    • In the “Begin the task” dropdown, select “On a schedule”.
    • Set it to “Weekly”, choose Saturday, and specify the time as 20:00.
  4. Configure Actions

    • Switch to the “Actions” tab.
    • Click on “New”.
    • In the “Action” dropdown, select “Start a program”.
    • In the “Program/script” field, enter:
      1
      
      shutdown
      
    • In the “Add arguments” field, enter:
      1
      
      /r /f /t 0
      
      Explanation:
      • /r: Restarts the computer
      • /f: Forces all applications to close
      • /t 0: Waits 0 seconds before restarting immediately
  5. Configure Additional Task Properties

    • Go to the “Conditions” tab and uncheck “Start the task only if the computer is on AC power”.
    • Switch to the “Settings” tab and make sure to check “If the task fails, restart every”.
  6. Save the Task
    Click OK to save the task. You may need to enter the username and password for an administrator account.


Method 2: Using PowerShell Script

If you prefer to use a script, you can create a scheduled task with PowerShell. Below is a sample script to set up a restart every Saturday at 8 PM:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# Define the task name
$TaskName = "WeeklyRestart"

# Create a trigger set for every Saturday at 8:00 PM
$Trigger = New-ScheduledTaskTrigger -Weekly -DaysOfWeek Saturday -At 8:00pm

# Create an action to execute the shutdown command
$Action = New-ScheduledTaskAction -Execute "shutdown.exe" -Argument "/r /f /t 0"

# Register the task
Register-ScheduledTask -TaskName $TaskName -Trigger $Trigger -Action $Action -Description "Restart server every Saturday at 8 PM" -User "SYSTEM" -RunLevel Highest

Save this script as a .ps1 file and run it to schedule the task.


Verify the Task

  • In Task Scheduler, find the task you created under “Task Scheduler Library”.
  • Right-click the task and select “Run” to ensure it executes properly.

After completing these configurations, the Windows Server will automatically restart every Saturday at 8 PM.