Thank you for being a valued part of the CNET community. As of December 1, 2020, the forums are in read-only format. In early 2021, CNET Forums will no longer be available. We are grateful for the participation and advice you have provided to one another over the years.

Thanks,

CNET Support

General discussion

event triggered scheduled tasks

Jul 6, 2004 10:50AM PDT

Hello,

i'm trying to schedule a task on a windows 2003 system remotely from an XP system using vbscript. I discovered the handy win32_ classes and i wrote this script to try to open notepad remotely using the win32_ScheduledJob class:


Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")

objSWbemLocator.Security_.ImpersonationLevel = 3

Set objSWbemServices = objSWbemLocator.ConnectServer _
(strComputer,"root\cimv2", strComputer &"\"& strUser, strPassword)

Set objNewJob = objSWbemServices.Get("Win32_ScheduledJob")

errJobCreated = objNewJob.Create _
("Notepad.exe", schTime, _
False , , , True, JobID)

If errJobCreated <> 0 Then
Wscript.Echo "Error on task creation"
Else
Wscript.Echo "Task created"
End If


I noticed that i was limitted to running a task at a specific UTC time -->schTime (e.g. "********090000.000000-300" - 9AM standard eastern time). This led to problems because on the remote computer the time that the scheduler was setting for the task was always 1 hour off even though the windows clock was set to the right time. I would much rather be able to force a task to run (remotely) after creating it, when i want, or making that task event triggered so that when i trigger a system event remotely the specific task runs. In effect im ignoring the task's scheduled time because it's a hassle.

Any ideas how to accomplish this?

Discussion is locked

- Collapse -
Re: event triggered scheduled tasks
Jul 10, 2004 10:35AM PDT
- Collapse -
Re: event triggered scheduled tasks
Jul 11, 2004 1:19PM PDT

both machines are set to EAST for local time. I made sure of that. Everything on both machines seems to say that they have the same date and time.. i think it's the Create function that i'm passing to the newObj object that is interpretting the time differently and giving me the one hour difference..

i cant explain it another way.
shady

- Collapse -
The time is...
Jul 11, 2004 1:44PM PDT

The area of what time it is, is not handled well my Microsoft. For a prime example, look at the time stamps for CDR files on Windows 98, 2000 or XP. Hopefully you'll see that issue...

The only hope I've had is to use time calls (API) that we can ask for UTC and no daylight savings.

For "real" applications, a central timesource is asked.

Bob