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.
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.
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.