Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remotely Scheduling a Task

Status
Not open for further replies.

shades44

Programmer
Jun 14, 2004
25
CA
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 code 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?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top