在 vbs 上运行脚本的脚本

在 vbs 上运行脚本的脚本

大家好我有一个关于 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)

如何让shutdown.vbs不在9:30运行一次而是在9:30到12:00之间运行

答案1

Create每次您想要安排任务时,您都需要执行一次。

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)
.
.
.

或者在变量中设置时间并增加它并Create在循环中执行。

相关内容