Page 1 of 1 1
Topic Options
#147039 - 2005-09-02 01:13 PM Newbie Shell
Rooster10 Offline
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
#147040 - 2005-09-02 01:43 PM Re: Newbie Shell
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
The %comspec% part in the code below will open a new cmd window where your command will be executed.
The /c will close the command window when the thing to execute is done.

Code:

SHELL "%COMSPEC% /C COPY Z:\FILE.TXT C:\"

_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#147041 - 2005-09-02 01:49 PM Re: Newbie Shell
Richard H. Administrator Offline
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
#147042 - 2005-09-02 02:08 PM Re: Newbie Shell
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Sorry My bad.
The start thingy slipped my mind. At least the /c part is correct
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#147043 - 2005-09-02 02:23 PM Re: Newbie Shell
Richard H. Administrator Offline
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
#147044 - 2005-09-02 02:37 PM Re: Newbie Shell
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Did you mean to say "asynchronously"?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#147045 - 2005-09-02 03:03 PM Re: Newbie Shell
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
No, I did mean synchronously, literally "at the same time".

I know it is confusing, especially when used to describe login scripts.

Top
#147046 - 2005-09-02 03:34 PM Re: Newbie Shell
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
the last test I did, you are not able to spawn new windows in wkix32.
_________________________
!

download KiXnet

Top
#147047 - 2005-09-02 03:45 PM Re: Newbie Shell
Richard H. Administrator Offline
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
#147048 - 2005-09-02 04:47 PM Re: Newbie Shell
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
then Ruud must have changed the behavior.

nope.
tried just without start.
now window is created.
all the output of comspec is spilled into same console window with the output of wkix32.
this is the case with wkix32.exe 4.50
_________________________
!

download KiXnet

Top
#147049 - 2005-09-02 04:49 PM Re: Newbie Shell
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
with start you get a separate window.
so indeed, that is working now.

but, without start, you won't get separate console with wkix32.
_________________________
!

download KiXnet

Top
#147050 - 2005-09-03 03:02 PM Re: Newbie Shell
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Why can you not use any of the PING() UDFs instead?
_________________________
There are two types of vessels, submarines and targets.

Top
#147051 - 2005-09-04 04:56 AM Re: Newbie Shell
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Why do you want the Ping command to have a DOS box at all? Why not just run it hidden? And why do you need another DOS box for KiX?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#147052 - 2005-09-05 09:37 AM Re: Newbie Shell
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
At a guess (considering the "-t" option) it's to spawn a seperate window to display a long term ping of an address to check for problems.

Why a seperate window? Guessing again but maybe it's spawned from a GUI, or he doesn't want to screw up the console output of the main program, or maybe he wants more than one active at a time as in the example.

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.158 seconds in which 0.121 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org