Solved

Make a Vb script call and run multiple scripts on wait

Posted on 2011-09-08
4
351 Views
Last Modified: 2012-05-12
I have a script that looks to see if a file exits then it runs the vbscript if the file is not thier then is gives the message no file found.  What is am trying to do it get the script to execute another VBscript after a given wait time.
HER IS AN EXAMPLE OF THE ORIGINAL SCRIPT THAT IS WORKING:
 Const PATH = "C:\Test1"
dim fso: set fso = CreateObject("Scripting.FileSystemObject")
dim folder: set folder = fso.getFolder(PATH)
if folder.files.Count <> 0 then
dim shell
 set shell=createobject("wscript.shell")
 shell.run "C:\Test1\Script\movenewest.vbs"
 set shell=nothing
Else
MsgBox "No files found!!"
----------END CODE-------------------
The addition to the cript that I worte that is not working looks like this and I get error messages. I am trying toget the script to wait 2 miniutes then run the second VBScript. Can someone help me??
EXAMPLE:
Const PATH = "C:\Test1"
dim fso: set fso = CreateObject("Scripting.FileSystemObject")
dim folder: set folder = fso.getFolder(PATH)
if folder.files.Count <> 0 then
dim shell
 set shell=createobject("wscript.shell")
 shell.run "C:\Test1\Script\movenewest.vbs"
 set shell=nothing
Then
WScript.Sleep 2000
dim shell
 set shell=createobject("wscript.shell")
 shell.run "C:\Test1\Script\Copyit.vbs"
 set shell=nothing
Else
MsgBox "No files found!!"
End If
0
Comment
Question by:RoadAmerica
  • 2
4 Comments
 
LVL 12

Expert Comment

by:rlandquist
ID: 36505913
FYI, wscript.sleep is in milliseconds, so 2000 = 2 seconds, 2 minutes would be 120000

It looks like you have 2 Then statements.  Remove the second Then and try again.

Also, please list what error messages you get.
0
 
LVL 53

Accepted Solution

by:
Bill Prew earned 500 total points
ID: 36505936
If you only want to run the second VBS if files are found, then this should be what you want.

Const PATH = "C:\Test1"
dim shell: set shell=createobject("wscript.shell")
dim fso: set fso = CreateObject("Scripting.FileSystemObject")
dim folder :set folder = fso.getFolder(PATH)
if folder.files.Count <> 0 then
   shell.run "C:\Test1\Script\movenewest.vbs"
   WScript.Sleep 120000
   shell.run "C:\Test1\Script\Copyit.vbs"
Else
   MsgBox "No files found!!"
End If
set shell = nothing

Open in new window

~bp
0
 

Author Closing Comment

by:RoadAmerica
ID: 36506363
LOL once again thank you sir for your help
0
 
LVL 53

Expert Comment

by:Bill Prew
ID: 36506435
Welcome.

~bp
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This is an addendum to the following article: Acitve Directory based Outlook Signature (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_24950055.html) The script is fine, and works in normal client-server domains…
Welcome, welcome!  If you are new to the series and haven't been following along, please take a brief moment to review the first three installments: Part 1 (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/A_266-VBScri…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question