1

Hello everybody I have a script on vbscript

Dim WSHShell, WinDir, Value, wshProcEnv, fso, Spath

Set WSHShell = CreateObject("WScript.Shell")

Dim objFSO, objFileCopy
Dim strFilePath, strDestination

Const OverwriteExisting = True
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set windir = objFSO.getspecialfolder(0)
objFSO.CopyFile "\dv.rt.ru\SYSVOL\DV.RT.RU\scripts\shutdown.vbs", windir&"\", OverwriteExisting

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\" _
& strComputer & "\root\cimv2")
JobID = "1"

Set colScheduledJobs = objWMIService.ExecQuery _
("Select * from Win32_ScheduledJob")
For Each objJob in colScheduledJobs
objJob.Delete
Next

Set objNewJob = objWMIService.Get("Win32_ScheduledJob")
errJobCreate = objNewJob.Create _
(windir & "\shutdown.vbs", "**093000.000000+660", _
True, 1 OR 2 OR 4 OR 8 OR 16 OR 32 OR 64, ,True, JobId)

How make that shutdown.vbs not run once at 9:30 but run for 9:30 to 12:00

Zypher
  • 37,405
  • 5
  • 53
  • 95
  • user31568: Your last question (an exact copy/paste of this one) got closed as "not a real question" meaning we couldn't tell exactly what you where looking for. You might want to edit in some more detail about what you are trying to do, what you have already tried, and what errors you are seeing. – Zypher May 18 '10 at 06:39
  • Crossposted: [StackOverflow](http://stackoverflow.com/questions/2854968/script-for-run-script) and [SuperUser](http://superuser.com/questions/142355/script-for-run-script-on-vbs). – Dennis Williamson May 18 '10 at 09:03
  • Since the user has no interest in following up on his question (even though an answer was proposed), can we close this? – gWaldo Sep 07 '10 at 19:52

1 Answers1

1

You will need to do a Create for each time that you want to schedule the task.

errJobCreate = objNewJob.Create _
(windir & "\shutdown.vbs", "********093000.000000+660", _
True, 1 OR 2 OR 4 OR 8 OR 16 OR 32 OR 64, ,True, JobId)
errJobCreate = objNewJob.Create _
(windir & "\shutdown.vbs", "********093500.000000+660", _
True, 1 OR 2 OR 4 OR 8 OR 16 OR 32 OR 64, ,True, JobId)
errJobCreate = objNewJob.Create _
(windir & "\shutdown.vbs", "********094000.000000+660", _
True, 1 OR 2 OR 4 OR 8 OR 16 OR 32 OR 64, ,True, JobId)
.
.
.

Or set the time in a variable and increment it and do the Create in a loop.

Dennis Williamson
  • 62,149
  • 16
  • 116
  • 151