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
Solved

Make a Vb script call and run multiple scripts on wait

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

791 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