Solved

Make a Vb script call and run multiple scripts on wait

Posted on 2011-09-08
4
345 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 51

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 51

Expert Comment

by:Bill Prew
ID: 36506435
Welcome.

~bp
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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…
In this article we want to have a look at the directory attributes which are used by Microsoft to store the so called Security Identifiers (SID). These SIDs plays an important role in delegating and granting permissions and in authentication of trus…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

708 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

15 Experts available now in Live!

Get 1:1 Help Now