Discussion:
VBScript Scheduled Task Problem
(too old to reply)
Hiwj
2009-08-24 09:04:01 UTC
Permalink
I am trying to run a script to reboot my servers with a scheduled task
(running as the Administrator):

Set OpSysSet =
GetObject("winmgmts:{(Shutdown)}!\\.\root\cimv2").ExecQuery("select * from
Win32_OperatingSystem where Primary=true")
For Each OpSys in OpSysSet
OpSys.Reboot()
Next

The script doesn't work. However, if I logon as the Administrator and run
the script then it works fine.

What's the difference from running it logged on as the Administrator,
compared to running it from a scheduled task as the Administrator?
Dave Patrick
2009-08-27 02:48:59 UTC
Permalink
Scheduled Tasks|Advanced|View Log may provide some details. You might also
try using shutdown.exe Something like;

%systemroot%\system32\shutdown.exe -r
--
Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect
Post by Hiwj
I am trying to run a script to reboot my servers with a scheduled task
Set OpSysSet =
GetObject("winmgmts:{(Shutdown)}!\\.\root\cimv2").ExecQuery("select * from
Win32_OperatingSystem where Primary=true")
For Each OpSys in OpSysSet
OpSys.Reboot()
Next
The script doesn't work. However, if I logon as the Administrator and run
the script then it works fine.
What's the difference from running it logged on as the Administrator,
compared to running it from a scheduled task as the Administrator?
Loading...