A lot of tasks in Windows can be automated by using script files. To run a program or script you need to create a scheduled task.
You will find the Task Scheduler in the Windows control panel.
You will get an overview of all tasks regardless of whether they are created by you or others. Some programs can carry out tasks independently e.g. an automatic check for application updates.
You can add a task by clicking on “Add Scheduled Task”.
A wizard will appear. Click ’Next’
You will get an overview of all programs on your server or PC. If the program is not listed, you can browse to it through the ’Browse’ button but you can always change settings later.
Click Next. Dependent on the choices you made a window, where you can specify several criteria, will appear.
For example, if you choose the option Weekly the following screen will appear:
You may have to fill in the administrative password of your server or PC on the next screen. The last screen gives you the possibility to choose more advanced settings to run your task.
This screen looks as follows :
The task description. Here you can choose the program or script again in case you did not find the appropriate program at the beginning of the procedure.
The Schedule tab states the time to run the task and you get the opportunity to select more advanced settings e.g. you can configure start and end date, repeat a task.
You can add extra settings in the Settings tab.
You can adapt the security settings in the Security tab.
Once you have configured the settings, you can right-click the task in the task view to see its properties. The window you’ve already seen by ticking the Advanced Settings while creating the task, will pop-up again.
As a result the following window will reappear
In case of problems right-click the task and select start or stop. Follow the same procedure to remove, rename, copy and paste a task.
Create a Scheduled task to have your server reboot at a scheduled interval. This works on Windows server 2003 and newer. I have not looked for a solution on Windows server 2000, because we do not have any in out network.
Open the Scheduled Task
START ->All Programs ->Accessorier -> System Tools -> Scheduled Tasks
Double Click on the 'Add a New Scheduled Task'
Click 'Next'
Click on Browse to select the proper program and location to run. Navigate to 'C:WINDOWSSystem32shutdown.exe'
This is where you set how often you want to 'task' to exicute. So if you wanted your server to reboot weekly you select 'weekly'
This can be once a week at 3 AM or every Wednesady and Friday nights.
This is the user that the scheduled task will run as. I suggest using an account that has domain admin privileges.
At this point you would be done, if you wanted the server to shutdown at the scheduled time. We are going to select the Open Advanced options when I click finished. Then click Finish
In the Run option you will see the location of the shutdown program. we are going to add some options.
-r This wil have ther server shutdown and then restart
-f This will force the server to force any running application to close
-t 01 This is a time-out before shutdown.
so the full run command is:
C:WINDOWSsystem32shutdown.exe -r -f -t 01
Select Apply and then OK
You can also look at the scheduled taks properties and change the schedule or frequency of the reboots.
Just be a bit wary of any other scheduled tasks that would be running at the time you specify (Backups, SQL jobs etc.) as obviously they will fail if the server turns itself off half way through
Or you could type something like the following at the command prompt.
at 03:00 shutdown /r
This will add the scheduled task for the next occurence of that time only, to have it repeat lookup the at command help with 'at /?'.
You can check for tasks quickly by typing 'at' in the cmd prompt.
We have schedualed the servers to be doing nothing Sunday morning between midnight and 4:00 am so it is a great time for a schedualed reboot.
Then we can clear up the backlog of updates requiering a reboot.
I would like to point out how insecure this approach is because the password is in clear text in the registry.
I would like to recommend LogonExpert at http://www.logonexpert.com/
is there any way to force your server to reboot based on a trigger? if (xxy) stops responding, then (reboot)?
Yes, this is possible, however only for Windows Server 2008. Open the task scheduler, and select a task to modify or create a new one under the tiggers tab. You can trigger an event based off of an event log.
The Server is shutting down but it has a 'You can now recycle the power' screen and doesn't actually shutdown completely, therefore doesn't reboot.
How can one bypass that screen?
I am using. shutdown.exe -r -f -t 01
Never mind.
I used pstools and psshutdown -r works for me.
Thanks for this..it really has helped cut down on my weekly reboots. Works great.
I wrote this simple PS script. Works on 2008+
[CmdletBinding()]
Param(
[Parameter(Mandatory=$true,HelpMessage='RestartDate Format: dd-MM-yyyy HH:mm')]
[ValidateScript({[DateTime]::ParseExact($_, 'dd-MM-yyyy HH:mm', $null)})]
$RestartDate,
[Parameter(Mandatory=$true)]
[string]$Reason
)
$now = get-date
$PostponeTo = get-date($RestartDate)
$secToRestartTimeFromNow = $PostponeTo - $now
$sec = [math]::round($secToRestartTimeFromNow.TotalSeconds)
$cmd = 'shutdown /r /t $sec /d P:0:0 /c '$reason'
Write-Host 'Running:'
$cmd
Invoke-Expression -Command $cmd -Verbose
Write-Host
Write-Host 'Use following command to cancel: '
Write-Host 'shutdown /a'
Hmm, this is a better method than what I've used in the past.
We created a batch file with the same shutdown command and switches and would run the batch file instead. Never thought of executing the shutdown command with the appropriate switches in the Run line of the scheduled task.
In our instance we copied the batch file to a utility folder on each server then we'd create the scheduled task. I'm guessing with this method that you can export the scheduled task and then import it to other servers without having to copy any thing else.
I like it. Thank you
Thanks Scott. Simple and works great.
The only person that can directly logon the server (in our case) is the Admin so they are the only one that can access the registry so I don't see where the security issue is that was mentioned earlier.
One slight adjustment needed for 2016 and 2019
The arguments now go into a separate box just below the Program/script box next to Add arguments optional.
I have a problem with running a .bat
file in windows 2003. If I change the user to Admin, I can run it without any problem, but with SYSTEM as user, it will not run. The command is:
SCHTASKS /Create /SC Weekly /TN Import /TR 'c:pathtoprog.bat' /D Monday /ST 10:00 /F /RU SYSTEM
The .bat
file opens Python.exe
with a run file, and a configuration file, and the configuration file is placed in C:Documents and SettingsAdministratorApplication Data
.
Hope you can help.
Bosch dryers are provided with two manuals; one Installation Instruction manual and one Use and Care manual. Read all instructions before using the dryer. Search: bosch wtl 4513 in our database for free. Click to go to view bosch wtl 4513 search result. Download: Operating instructions, user manual, owner's manual, installation manual, workshop manual, repair. BOSCH WTL 4513: Download processing. Bosch wtl 4513 electronic manual. Download Bosch Wtl 4613 Manual.pdf - I need the user manual for Bosch WTL 4613. Manuals for bosch+wtl+4513+electronic+manual to download for viewing. Huge selection of Tumble dryer spares; belts, filters, thermostat kits, hinges and more. Genuine spare part for select Bosch & Siemens tumble dryers.
Don't run it as System. System was never intended to be used as an user anyways.
I have a batch file in Windows 7 Professional that runs RASDIAL and creates a VPN to Windows Server 2003. The batch file then maps a drive and then I do a backup routine. This batch file runs flawlessly by double clicking it.
Using Task Scheduler, the batch file executes properly except for the net use command. Here is the capture from the command window:
C:UsersMikeDesktopmixSBS Connect>rasdial mixsbs_vpn administrator password
Connecting to mixsbs_vpn..
Verifying username and password..
Registering your computer on the network..
Successfully connected to mixsbs_vpn.
Command completed successfully.
C:UsersMikeDesktopmixSBS Connect>net use * /delete /yes
You have these remote connections:
Z: mixSBSmix Data
Continuing will cancel the connections.
The command completed successfully.
C:UsersMikeDesktopmixSBS Connect>net use Z: 'mixSBSmix Data' password /USER:Administrator /PERSISTENT:YES
The command completed successfully.
C:UsersMikeDesktopmixSBS Connect>net use
New connections will be remembered.
Status Local Remote Network
-------------------------------------------------------------------------------
OK Z: mixSBSmix Data Microsoft Windows Network
The command completed successfully.
C:UsersMike>net use
New connections will be remembered.
Status Local Remote Network
-------------------------------------------------------------------------------
Unavailable Z: mixSBSmix Data Microsoft Windows Network
The command completed successfully.
The VPN connection shows in the NETWORKING AND SHARING CENTER but the mapped drive does not show in COMPUTER. Can someone tell me what I am doing wrong. Thanks.
Chas