Solved

Make a Vb script call and run multiple scripts on wait

Posted on 2011-09-08
4
357 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 54

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 54

Expert Comment

by:Bill Prew
ID: 36506435
Welcome.

~bp
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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ā€¦
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decadeā€¦

739 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