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,
Create a scheduled task to run the following command:
c:\windows\system32\cscript.exe PATH_TO_YOUR_VBS
You can certainly make a vbs file a scheduled task.
The caveat, though, is you want NOTHING to prompt the user...no inputs, no message boxes, nothing. Make sure you've handled and logged your exceptions or you could find yourself with a task that never completes (or worse, operations angrily calling you because a message box popped up at 3am and halted a production process)
on Windows 8: windows tasks that are triggering VBScripts having message boxes will only display the message boxes if the windows task is run under the same user who really is logged on the machine and the if the windows task is configured to "run only if the user is logged on"
I think this changed on windows 8, as on windows 7 I did not had to configure the task in that way
try this
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")