Computing.Net > Forums > Programming > Batch File - Start in a new window

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch File - Start in a new window

Reply to Message Icon

Name: shahramsh
Date: January 25, 2006 at 14:48:26 Pacific
OS: win xp pro
CPU/Ram: p4 3.2 gh
Comment:

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.



Sponsored Link
Ads by Google

Response Number 1
Name: wizard-fred
Date: January 25, 2006 at 16:41:02 Pacific
Reply:

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.


0

Response Number 2
Name: shahramsh
Date: January 25, 2006 at 16:53:36 Pacific
Reply:

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,


0

Response Number 3
Name: IVO
Date: January 26, 2006 at 03:28:38 Pacific
Reply:

The following does what you need

@Echo Off

If not "%1"=="" GoTo %1

Echo.
Echo Window 1

Set Var=10
Start /w Cmd /C %0 :START

GoTo :EOF
:START
echo %var%
if %var%==0 goto :END
set /a var=%var%-1
goto START
:END
Pause

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



0

Response Number 4
Name: shahramsh
Date: January 26, 2006 at 17:29:29 Pacific
Reply:

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 again

Shahram


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch File - Start in a new window

Edit batch file while in a cmd window www.computing.net/answers/programming/edit-batch-file-while-in-a-cmd-window/19639.html

Batch File: Integers in a Txt File Variable www.computing.net/answers/programming/batch-file-integers-in-a-txt-file-variable/19900.html

Open batch in new window from batch www.computing.net/answers/programming/open-batch-in-new-window-from-batch/17043.html