Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Using WSH Run method

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,553
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Using WSH Run method
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Using WSH Run method - 1/9/2002 8:45:26 PM   
  imav8n

 

Posts: 95
Score: 0
Joined: 7/3/2001
From: USA
Status: offline
I've got a series of scripts...some are batch, some .vbs...that I'm trying to consolidate into a single .vbs script.

I'm able to run the batch commands from a .vbs using Windows Scripting Host's Run method, but I can't figure out how to make it close the command window after I'm done.

Code Example:
--------------------------------------------------------
Set WshShell = Wscript.CreateObject("Wscript.shell")
command = "%COMSPEC% /k "
Domainlist = Array("CORP", "NORTHAMERICA", "SOUTHAMERICA")

For each domain in DomainList
dos_command = command & "netdom query dc /domain:" & domain & " >> test\" & domain & ".txt"
WshShell.Run (dos_command)
Next
---------------------------------------------------------

This should execute "NETDOM QUERY DC" for each domain in the array and dump it to a text file...which it does successfully, but it leaves the command window open after the command executes. In this case, I'm left with 3 windows open.

Anybody have any idea how to get those windows to close on exit?
Thanks in advance!


T

~imav8n
Failure is not an option.....it comes bundled with the software.
 
 
Post #: 1
 
 Re: Using WSH Run method - 1/10/2002 11:44:26 AM   
  Tory

 

Posts: 16
Score: 0
Joined: 11/13/2001
From: USA
Status: offline
Are the programs/.bat routines interactive? If not you should use the Windows style option "0" like this:

WShell.Run(Batch_file,0)

The zero means "Run a program or Script in the Background"

There is also a third feature. The syntax for the Run method is this:

WShell.Run("command", WindowStyle, WaitOnReturn)

The WaitOnReturn is Boolean (True/False) if set to true the script waits for the command to exit before moving on. If set to FALSE (which is the default), the script launches "program" and spawns a new process for it.

BTW - There are 10 different Window styles to choose from. You should goto

www.devguru.com and look up the others. There may be a better choice than running the scripts and .bat files in the background.

-Tory
San Jose, CA



Edited by - tory on 01/10/2002 17:46:41

Edited by - tory on 01/10/2002 17:48:25

(in reply to imav8n)
 
 
Post #: 2
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Using WSH Run method Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts