start with /wait and /b together

  • Thread starter Thread starter jan_bar
  • Start date Start date
J

jan_bar

Hi,

I want to start command line tool from a batch, keep the same command window
and wait for it at the same time. Sample:

start "test" /low /wait /b "path\to\some\command\line\tool.exe"

The problem is, that /wait and /b doesn't work together. When the /b is
specified, the /wait is ignored - and any Ctrl-C will nto reach the running
tool.exe. How can I solve this?
In fact, I just want to start the tool.exe with lower priority, start /low
seems to be the cheapest way.

Thanks, Jan
 
jan_bar said:
Hi,

I want to start command line tool from a batch, keep the same command
window
and wait for it at the same time. Sample:

start "test" /low /wait /b "path\to\some\command\line\tool.exe"

The problem is, that /wait and /b doesn't work together. When the /b is
specified, the /wait is ignored - and any Ctrl-C will nto reach the
running
tool.exe. How can I solve this?
In fact, I just want to start the tool.exe with lower priority, start /low
seems to be the cheapest way.

Thanks, Jan

So what you would want to do is

* set lower priority
* execute TOOL
* restore original priority

the problem being that a tool to set the priority from the command line
isn't supplied by Uncle Bill, and isn't an option in TASKMANAGER which is
dumbly clicky-clicky?

* beyondlogic.org has a freeware program that is claimed set priority of a
process. Google "command line change task priority"

-------------------

Perhaps you could split the batch into two, as the last command of the first
half "start" a new batchfile with LOW priority, containing just two lines:

TOOL
start /originalpriority secondpartoforiginalbatchfile
 
In said:
So what you would want to do is

* set lower priority
* execute TOOL
* restore original priority

But I think OP needs to "wait". Why wait is unknown. Does the
TOOL return data? Or do you just need to know when it is finished?

In the latter case a loop with a process lister that exits when the
"tool" process ends might suffice for that. pslist.exe might be
useful as it sets errorlevel (found/not found).
the problem being that a tool to set the priority from the
command line isn't supplied by Uncle Bill, and isn't an option
in TASKMANAGER which is dumbly clicky-clicky?

I think he said. START "" /LOW
would work?
* beyondlogic.org has a freeware program that is claimed set
priority of a process. Google "command line change task
priority"

Interesting. I did not know of that one.
http://beyondlogic.org/solutions/processutil/processutil.htm

There is another
http://www.ntwind.com/software/utilities/hstart.html
Hidden Start (hstart)
I have not yet used it. It offers named class priority such as
"/IDLE".

And I have a vague recollection of one of the "process starter"
tools (forgotten which one) has a Priority argument available...
 
Mark V said:
But I think OP needs to "wait". Why wait is unknown. Does the
TOOL return data? Or do you just need to know when it is finished?

In the latter case a loop with a process lister that exits when the
"tool" process ends might suffice for that. pslist.exe might be
useful as it sets errorlevel (found/not found).

Why go to all that bother?

TOOL

will execute TOOL and wait until it's finished. The OP wants TOOL to be run
at LOW priority. WHY is beyond me - but that is what was asked.
I think he said. START "" /LOW
would work?

Yes - but it WON'T work with /B and will create a new window. I believe that
the idea is to have only one window and have the TOOL process running with
LOW priority.

This can be achieved by the following, given Demo1.bat is on the desktop -
I've used EDIT since we're not aware of what TOOL is.

----- batch demo1 begins -------
[1]@echo off
[2]start "" /low /max demo2.bat
[3]exit
------ batch demo1 ends --------


----- batch demo2 begins -------
[1]edit junk.txt
[2]start "" /normal /max demo3.bat
[3]exit
------ batch demo2 ends --------


----- batch demo3 begins -------
[1]echo now in demo3!
[2]pause
[3]exit
------ batch demo3 ends --------

Lines start [number] - any lines not starting [number] have been wrapped
and should be rejoined. The [number] that starts the line should be removed
 
Thank you Mark and "billious", let me clarify:

TOOL - Maven (command line Java project management framework)
LOWER - the build takes some time and with lower it works better with
foreground processes
WAIT - without wait the TOOL runs detached, it means that I cannot stop it
with Ctrl-C
In the same window (/B) - The TOOL is actually started from Eclipse and the
command prompt is in integrated window

TaskManager - no, this is not an option, I am not slave of my PC :-)

beyondlogic.org will not work, there will be more processes called
java.exe...

I know how to write a C/C++ tool that will do the task, but I think someone
already did it.

Thank you, Jan
 
In said:
Thank you Mark and "billious", let me clarify:

TOOL - Maven (command line Java project management framework)
LOWER - the build takes some time and with lower it works
better with foreground processes
WAIT - without wait the TOOL runs detached, it means that I
cannot stop it with Ctrl-C
In the same window (/B) - The TOOL is actually started from
Eclipse and the command prompt is in integrated window

TaskManager - no, this is not an option, I am not slave of my PC
:-)

beyondlogic.org will not work, there will be more processes
called java.exe...

I know how to write a C/C++ tool that will do the task, but I
think someone already did it.

More clear now. I am not familiar with the tools you use. Any
chance that just a
START "" /LOW CMD.EXE /C TOOL
will cut it? Assuming "other processes" invoked from TOOL ought to
inherit the Priority. But depends on how they are started from
TOOL of course. I may be way off the mark since I do not fully
comprehend the problem, so FWIW.
 
Thanks Mark
More clear now. I am not familiar with the tools you use. Any
chance that just a
START "" /LOW CMD.EXE /C TOOL
will cut it? Assuming "other processes" invoked from TOOL ought to

this is will open new console window. The TOOL must run in the *same*
window, see me previous post.

Thank you, Jan
 
jan_bar said:
Thanks Mark


this is will open new console window. The TOOL must run in the *same*
window, see me previous post.

Thank you, Jan

Since you seem to have ignored it, here's a way to do what I believe you
want. It's not elegant, but it'll work.

This can be achieved by the following, given Demo1.bat is on the desktop -
I've used EDIT since we're not aware of what TOOL is.

----- batch demo1 begins -------
[1]@echo off
[2]start "" /low /max demo2.bat
[3]exit
------ batch demo1 ends --------


----- batch demo2 begins -------
[1]edit junk.txt
[2]start "" /normal /max demo3.bat
[3]exit
------ batch demo2 ends --------


----- batch demo3 begins -------
[1]echo now in demo3!
[2]pause
[3]exit
------ batch demo3 ends --------

Lines start [number] - any lines not starting [number] have been wrapped
and should be rejoined. The [number] that starts the line should be removed
 
In said:
Thanks Mark


this is will open new console window. The TOOL must run in the
*same* window, see me previous post.

Ok, then I have nothing further useful.

But, Perhaps the original CMD can alter itself to a lower priority
first, then reset after TOOL et. al. returns? Just musing...
 
Thank you
Since you seem to have ignored it, here's a way to do what I believe you
want. It's not elegant, but it'll work.

I did not ignored it, but it doesn't solve my problem because it opens new
console windows.

Jan
 
jan_bar said:
Thank you


I did not ignored it, but it doesn't solve my problem because it opens new
console windows.

Jan

Evidently you didn't TRY it. Only ONE console window is ever open. The fact
that it's a NEW window should be irrelevant.
 
Of course I did. There is only one console window but threee different
processes. As I already wrote, the console window will actual be part of IDE
application, so it must stay there. In fact the IDE doesn't create the
console window, it spawns new cmd process and redirects stdin, stdout and
stderror to self. The redirection will be ignored by new console.

Jan
 
jan_bar said:
Hi,

I want to start command line tool from a batch, keep the same command window
and wait for it at the same time. Sample:

start "test" /low /wait /b "path\to\some\command\line\tool.exe"

The problem is, that /wait and /b doesn't work together. When the /b is
specified, the /wait is ignored - and any Ctrl-C will nto reach the running
tool.exe. How can I solve this?
In fact, I just want to start the tool.exe with lower priority, start /low
seems to be the cheapest way.

Thanks, Jan

It appears the order of the switches in makes a difference. The following
command seems to wait for me (/wait switch last).

start /b /low /wait tool.exe
 
Thanks Todd
It appears the order of the switches in makes a difference. The following
command seems to wait for me (/wait switch last).

start /b /low /wait tool.exe

yes, it works, thank you.

Here is my test batch, the TOOL is "ping -n 10 google.com"

test.bat:
@echo off

echo.
echo Start of ping

start "pinging" /b /wait /low ping -n 10 google.com

echo.
echo End of ping
 
Back
Top