Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I am looking for a way to be able to execute series of command from a batch in a new window (without a need for a second batch file),
for example execute these:
echo hello
echo goodbye
The first problem is that with "start /w" you can not execute more than one command in 1 window,However if using < start /w cmd /c "echo hello & echo goodbye" > , this will work fine for this simple case of echo,
But the problem is what I want to execute has more functions and is using variables
(ie
set var=10
:start
echo %var%
if %var%==0 goto end
set /a var=%var%-1
goto start
:end
)on the other hands it's possible to use "call :label" to run through command after a label, but it will not open in a new windows and "start /w call :lable" will be referreing to a nonexistance label.
is there anyways to do this?
Thanx in advance.
Shahram.

I don't think you can have a new process run in another window. Each window has its own thread and starting a new window starts a new environment. To use variables you need a common data storage area.

with
start /w cmd /c "command & command &..."
I can run as many commands as I want internal (echo,if, for,...) or external, and I may be able to use a global variable,
but the problem is I want to produce a loop that is not possible cause you can't have labels,I am looking if there is anyway (any command) to make this loop,

The following does what you need
@Echo Off
If not "%1"=="" GoTo %1
Echo.
Echo Window 1Set Var=10
Start /w Cmd /C %0 :STARTGoTo :EOF
:START
echo %var%
if %var%==0 goto :END
set /a var=%var%-1
goto START
:END
PauseWhere :EOF is the standard exit point for NT batch routines and needs no declatation.
If you need more support on this topic or have any question about the code I show, post again.

That is a very good solution,
I just didn't think that I actually could call specific part of the same script,Thank you very much,
I am gonna work on, but it definitly shouldn't have any problems, as the solution is clear.
thanx againShahram

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |