Problems Scheduling a VBScript to run on XP - TechRepublic
Question
June 26, 2008 at 04:14 PM
eddieduce

Problems Scheduling a VBScript to run on XP

by eddieduce . Updated 18 years, 1 month ago

I am attempting to schedule a VBScript to run remotely. I run it with administrative rights, I manage to get it scheduled but as soon as it is time to run it, it disappears but nothing is displayed, which is fine but nothing is changed.

/////////////////////////////////
”http://motevich.blogspot.com/2007/11/execute-program-on-remote-computer.html

‘ Succesfull in setting scheduled task locally
‘ Failed to connect remotely.
strComputer = “.” ‘Connects to specified computer.
strCommand = “dflt_Printer.vbs” ‘Opens specified file from OS root.

Const INTERVAL = “n”
Const MINUTES = 1

Set objWMIService = GetObject(“winmgmts:\\” & strComputer & “\root\cimv2”)
Set objScheduledJob = objWMIService.Get(“Win32_ScheduledJob”)
Set objSWbemDateTime = CreateObject(“WbemScripting.SWbemDateTime”)

objSWbemDateTime.SetVarDate(DateAdd(INTERVAL, MINUTES, Now()))
errReturn = objScheduledJob.Create(strCommand, objSWbemDateTime.Value, False, 0, 0, True, intJobID)

If errReturn = 0 Then
Wscript.Echo “DefaultPrinter Script was started with a process ID: ” & intJobID
Else
Wscript.Echo “DefaultPrinter Script could not be started due to error: ” & errReturn
End If

This discussion is locked

All Comments