#147039 - 2005-09-02 01:13 PM
Newbie Shell
|
Rooster10
Fresh Scripter
Registered: 2004-10-14
Posts: 14
|
Hi,
Can you help?, I am trying to shell out a new DOS window to run a ping command...when I try at the moment, it runs in the current DOS box I have open.
I want to shell a window and run say ping 10.10.10.10 -t
This has to be a new window so when you close it, it doesn't affect other open DOS boxes...
Any Ideas? Cheers
Dan
|
|
Top
|
|
|
|
#147041 - 2005-09-02 01:49 PM
Re: Newbie Shell
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Quote:
The %comspec% part in the code below will open a new cmd window where your command will be executed.
It won't you know (unless you are using wkix32).
You need the magic "start" keyword to start a new console window: Code:
Shell '"'+%COMSPEC%+'" /C start PING -t 10.10.10.10'
|
|
Top
|
|
|
|
#147043 - 2005-09-02 02:23 PM
Re: Newbie Shell
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
No worries.
BTW Dan, the code will work synchronously by default, i.e. once the window is opened the script will continue to run.
For example, the following code will open three seperate windows with pings for each IP address - all three windows will ping away at the same time: Code:
For Each $sServer in Split("10.9.0.41,10.9.0.42,130.13.42.1",",") Shell '"'+%COMSPEC%+'" /C start "Pinging '+$sServer+'" PING -t '+$sServer Next "Waiting for a key-press..." Get $
If you want to wait for each window to close before opening the next one you need to use the "/wait" switch: Code:
For Each $sServer in Split("10.9.0.41,10.9.0.42,130.13.42.1",",") Shell '"'+%COMSPEC%+'" /C start /wait "Pinging '+$sServer+'" PING -t '+$sServer Next "Waiting for a key-press..." Get $
|
|
Top
|
|
|
|
#147047 - 2005-09-02 03:45 PM
Re: Newbie Shell
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Quote:
the last test I did, you are not able to spawn new windows in wkix32.
Just tried it - it works fine for me.
In fact the sample code spawns an additional console for the "waiting for keypress" prompt too.
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 2220 anonymous users online.
|
|
|