Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
576 views
in Technique[技术] by (71.8m points)

vbscript - can .vbs file be a scheduled script?

I have written a .vbs script which presently is run manually by users. How can I make this script schedule itself in Task Scheduler (to run at a fixed time each day automatically) on Windows XP and Windows 7 the first time it is executed manually?

EDIT

    Option Explicit

    Dim oShell : Set oShell = WScript.CreateObject ("WScript.Shell")
    Dim FSO : set FSO = CreateObject("Scripting.FileSystemObject") 
    Dim StartTime,Elapsed 

    'msgBox(oShell.CurrentDirectory)
    'MsgBox(FSO.GetFile(Wscript.ScriptFullName).ParentFolder )
    oShell.CurrentDirectory = FSO.GetFile(Wscript.ScriptFullName).ParentFolder

    StartTime = Timer

    oShell.run "ParentChildLinkFinal.vbs", 1, True
    oShell.run "Parent_Child_Merge_final.vbs", 1, True
    oShell.run "CycleTime.vbs", 1, True
    oShell.run "Baddata.vbs", 1, True
    oShell.run "Matrixrefresh.vbs", 1, True

    Elapsed = Timer - StartTime

    MsgBox("Total time taken to finish this task:" & Elapsed & "in Seconds")

Thanks,

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Create a scheduled task to run the following command:

c:windowssystem32cscript.exe PATH_TO_YOUR_VBS

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...