Solved

Make a Vb script call and run multiple scripts on wait

Posted on 2011-09-08
4
348 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 52

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 52

Expert Comment

by:Bill Prew
ID: 36506435
Welcome.

~bp
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Recently I finished a vbscript that I thought I'd share.  It uses a text file with a list of server names to loop through and get various status reports, then writes them all into an Excel file.  Originally it was put together for our Altiris server…
Script to copy or move mouse-selected collection of files plus targets referenced by shortcuts (.lnk) The purpose of this article is to help illuminate the real challenges and options available (where they may exist) for utilizing simple scriptin…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
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.

911 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now