Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Server > Scripting > VBScript Scheduled Task Problem

Reply
Thread Tools Display Modes

VBScript Scheduled Task Problem

 
 
Hiwj
Guest
Posts: n/a

 
      08-24-2009
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?
 
Reply With Quote
 
 
 
 
Dave Patrick
Guest
Posts: n/a

 
      08-27-2009
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


"Hiwj" wrote:
>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?


 
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to schedule a vbscript as a Scheduled Task in Server 2003 Rich Windows Server 15 07-15-2009 09:24 PM
Scheduled Task problem... RSteph Windows Server 1 03-02-2009 09:38 PM
Scheduled task problem Brian Davidson Windows 64 Bit 1 09-17-2007 04:30 PM
Scheduled Task Problem Waggers Windows Small Business Server 2 09-12-2007 12:33 PM
Scheduled Task Cannot Run a VBScript Amanda George Scripting 2 01-05-2005 05:51 PM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59