简体   繁体   中英

Run scheduled task from VBScript

How to run scheduled task inside .vbs script?

It's not about how to schedule .vbs script inside Task Scheduler.

But I have a task that I want to run by running this one .vbs script.

The simplest way is to shell out to the schtasks commandline utility.

taskname = "something"
Set sh = CreateObject("WScript.Shell")
rc = sh.Run("schtasks /run /tn """ & taskname & """")

You could also use the Task Scheduler scripting API , but that would require more code.

taskname = "something"

Set sched = CreateObject("Schedule.Service")
sched.Connect()

Set root = sched.GetFolder("\")
Set task = root.GetTask(taskname)

task.Run Null

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM