1

我编写了一个 .vbs 脚本,目前由用户手动运行。第一次手动执行时,如何在 Windows XP 和 Windows 7 上的任务计划程序中自行安排此脚本(每天自动在固定时间运行)?

编辑

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

谢谢,

4

4 回答 4

2

创建计划任务以运行以下命令:

c:\windows\system32\cscript.exe PATH_TO_YOUR_VBS
于 2012-12-30T01:22:18.933 回答
0

您当然可以使 vbs 文件成为计划任务。

但是,需要注意的是,您不想提示用户……没有输入,没有消息框,什么都没有。确保您已经处理并记录了您的异常,否则您可能会发现自己的任务永远不会完成(或者更糟糕的是,操作会因为凌晨 3 点弹出消息框并停止生产过程而愤怒地打电话给您)

于 2013-01-02T21:26:42.123 回答
0

在 Windows 8 上:触发具有消息框的 VBScript 的 Windows 任务将仅在 Windows 任务在真正登录机器的同一用户下运行并且如果 Windows 任务配置为“仅在用户已登录”我认为这在 Windows 8 上发生了变化,因为在 Windows 7 上我不必以这种方式配置任务

于 2015-12-10T09:04:50.443 回答
-3

尝试这个

X=MsgBox("Take the Quiz!")

name=inputbox("Name")

q1=inputbox("Question 1 - How many days are there in a leap Year?")

q2=inputbox("Question 2 - How many Suns does Neptune have?")

q3=inputbox("Question 3 - What is your name?")

q4=inputbox("Question 4 - What did one computer say to the other?")

q5=inputbox("Question 5 - Why did the chicken cross the road?")

msgbox("Answers!")

msgbox("Q1 - How many days are there in a leap Year?, you answered ") + q1 + (" ,the correct answer is 366")

msgbox("Q2 - How many Suns does Neptune have?, you answered ") + q2 + (" ,the correct answere is one, our sun.")

msgbox("Q3 - What is your name?, you answered ") + q3 + (", the correct answer is ") + name + (" or is it?")

msgbox("Q4 - What did one computer say to the other?, you answered ") + q4 + (", the correct answer is, 011100110111010101110000 (Binary code for sup)")

msgbox("Q5 - Why did the chicken cross the road?, you answered ") + q5 + (", the correct answer is To get to the other side")

msgbox("Well done, ") + name + (" you have completed the quiz")
于 2013-09-26T02:31:24.387 回答