Shutdown start up script
From: David (anonymous_at_discussions.microsoft.com)
Date: 02/22/04
- Previous message: LMY: "Custom Attributes"
- Messages sorted by: [ date ] [ thread ]
Date: Sun, 22 Feb 2004 07:33:11 -0800
>-----Original Message-----
>I am wanted to create a script to shutdown my PC at 9:02pm
>on Monday - Thursday and 5:02pm on Friday - Sunday. Is
>this an easy task in NT, 2000, and XP?
>.
>
I wanted to do something similar to this, but I only
wanted machines to be rebooted only if they have been left
on longer than x days.
Heres what I came up with:
I used a machine startup script (startupscript.cmd) to
copy uptime.exe and uptimecheck.cmd to a local directory.
It then creates a task that runs daily at 3am. The task
does nothing if they are rebooted daily. You will need to
replace %logonserver% with the name of a valid DC. This
variable is not set until someone logs on.
startupscript.cmd
---------------
REM Create OIT directory under Windows directory and copy
Uptime files to it
if not exist %windir%\oit md %windir%\oit
xcopy %logonserver%\netlogon\uptime.exe /d /c %windir%
\oit\.
xcopy %logonserver%\netlogon\uptimecheck.cmd /d /c %windir%
\oit\.
REM Schedule UptimeCheck Task
Wscript shutdown.vbs
exit
shutdown.vbs
---------------
strComputer = "."
Set objWMIService = GetObject("winmgmts:"
& "{impersonationLevel=impersonate}!\\" & strComputer
& "\root\cimv2")
Set objNewJob = objWMIService.Get("Win32_ScheduledJob")
errJobCreated = objNewJob.Create("%windir%
\oit\uptimecheck.cmd", "********112200.000000-360", True ,
1 OR 2 OR 4 OR 8 OR 16 OR 32 OR 64, , , JobID)
uptimecheck.cmd
---------------
c:
cd %windir%\oit
uptime > %computername%.txt
FOR /f "eol=, tokens=6*" %%1 in (%computername%.txt) do if
%%1 GEQ 7 shutdown.exe -r -f -t 120 -d p -c "OIT is
restarting your computer in 2 minutes. Please save any
work now. Thank you."
- Previous message: LMY: "Custom Attributes"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|