Discussion:
CMD waits app to return if commands passed as arguments ?
(too old to reply)
Vilius Mockûnas
2009-08-14 13:19:58 UTC
Permalink
Hello,

By default cmd doesn't wait application to return if I type command
sol.exe
cmd /c sol.exe
I want cmd to return immediately but I must use commands as arguments using
/k or /c switches.
How do I solve this ?

thanks
Vilius
Pegasus [MVP]
2009-08-14 14:35:06 UTC
Permalink
Post by Vilius Mockûnas
Hello,
By default cmd doesn't wait application to return if I type command
sol.exe
cmd /c sol.exe
I want cmd to return immediately but I must use commands as arguments
using /k or /c switches.
How do I solve this ?
thanks
Vilius
You do it like so:

start /b "Vilius' Program" sol.exe
\Rems
2009-08-17 16:39:01 UTC
Permalink
Post by Vilius Mockûnas
Hello,
By default cmd doesn't wait application to return if I type command
sol.exe
cmd /c sol.exe
I want cmd to return immediately but I must use commands as arguments using
/k or /c switches.
How do I solve this ?
thanks
Vilius
Running the command from within a batch? or by command line?

try the difference between,
cmd /c Start ""/b ping sol.exe
and,
cmd /c Start cmd /c sol.exe

In a batch you can skip the leading "cmd /c".

\Rems
Pegasus [MVP]
2009-08-17 16:46:46 UTC
Permalink
Post by \Rems
Post by Vilius Mockûnas
Hello,
By default cmd doesn't wait application to return if I type command
sol.exe
cmd /c sol.exe
I want cmd to return immediately but I must use commands as arguments using
/k or /c switches.
How do I solve this ?
thanks
Vilius
Running the command from within a batch? or by command line?
try the difference between,
cmd /c Start ""/b ping sol.exe
and,
cmd /c Start cmd /c sol.exe
In a batch you can skip the leading "cmd /c".
\Rems
In your command
cmd /c Start ""/b ping sol.exe
you can omit the extra command processor. It is sufficient to use
start /b "" sol.exe

In your command
cmd /c Start cmd /c sol.exe
you can omit both extra command processors. Again it is sufficient to use
start /b "" sol.exe

This command will work equally well at the Command Prompt or in batch files.
\Rems
2009-08-17 18:36:02 UTC
Permalink
Post by Pegasus [MVP]
Post by \Rems
Post by Vilius Mockûnas
Hello,
By default cmd doesn't wait application to return if I type command
sol.exe
cmd /c sol.exe
I want cmd to return immediately but I must use commands as arguments using
/k or /c switches.
How do I solve this ?
thanks
Vilius
Running the command from within a batch? or by command line?
try the difference between,
cmd /c Start ""/b ping sol.exe
and,
cmd /c Start cmd /c sol.exe
In a batch you can skip the leading "cmd /c".
\Rems
In your command
cmd /c Start ""/b ping sol.exe
you can omit the extra command processor. It is sufficient to use
start /b "" sol.exe
In your command
cmd /c Start cmd /c sol.exe
you can omit both extra command processors. Again it is sufficient to use
start /b "" sol.exe
This command will work equally well at the Command Prompt or in batch files.
Yes I know that,
but thank you for clarifying.

Actually that was what I had in mind saying: "In a batch you can skip the
leading cmd /c ". And you're right, you also don't need the leading cmd /c
when typing it from a DOS-prompt, obviously.
The OP mensioned: "type command interactively >sol.exe"

However, note that the OP did also stated: "but I must use commands as
arguments using /k or /c switches" - So I wonder why that is... !
- The leading "cmd /c" IS needed when executing from Start | Run or using a
vbscript to run it.
- It could also be that the OP needs the supplement box (sample 2) for some
purpose.
Anyway, that is why my two samples look as they do, in addition to the
correctly dos command you posted a few days ago.

Thanks.
\Rems
\Rems
2009-08-17 16:48:01 UTC
Permalink
Post by \Rems
Post by Vilius Mockûnas
Hello,
By default cmd doesn't wait application to return if I type command
sol.exe
cmd /c sol.exe
I want cmd to return immediately but I must use commands as arguments using
/k or /c switches.
How do I solve this ?
thanks
Vilius
Running the command from within a batch? or by command line?
try the difference between,
cmd /c Start ""/b ping sol.exe
and,
cmd /c Start cmd /c sol.exe
In a batch you can skip the leading "cmd /c".
\Rems
That should have been,

try the difference between,
cmd /c Start ""/b sol.exe
and,
cmd /c Start cmd /c sol.exe

In a batch you can skip the leading "cmd /c".
Are you running the command from within a batch? or from a prompt?

\Rems
Pegasus [MVP]
2009-08-17 17:09:20 UTC
Permalink
Post by \Rems
Post by \Rems
Post by Vilius Mockûnas
Hello,
By default cmd doesn't wait application to return if I type command
sol.exe
cmd /c sol.exe
I want cmd to return immediately but I must use commands as arguments using
/k or /c switches.
How do I solve this ?
thanks
Vilius
Running the command from within a batch? or by command line?
try the difference between,
cmd /c Start ""/b ping sol.exe
and,
cmd /c Start cmd /c sol.exe
In a batch you can skip the leading "cmd /c".
\Rems
That should have been,
try the difference between,
cmd /c Start ""/b sol.exe
and,
cmd /c Start cmd /c sol.exe
In a batch you can skip the leading "cmd /c".
Are you running the command from within a batch? or from a prompt?
\Rems
You still have too many command processors. You can drop the whole lot - try
it!
\Rems
2009-08-17 18:41:01 UTC
Permalink
Post by Pegasus [MVP]
Post by \Rems
Post by \Rems
Post by Vilius Mockûnas
Hello,
By default cmd doesn't wait application to return if I type command
sol.exe
cmd /c sol.exe
I want cmd to return immediately but I must use commands as arguments using
/k or /c switches.
How do I solve this ?
thanks
Vilius
Running the command from within a batch? or by command line?
try the difference between,
cmd /c Start ""/b ping sol.exe
and,
cmd /c Start cmd /c sol.exe
In a batch you can skip the leading "cmd /c".
\Rems
That should have been,
try the difference between,
cmd /c Start ""/b sol.exe
and,
cmd /c Start cmd /c sol.exe
In a batch you can skip the leading "cmd /c".
Are you running the command from within a batch? or from a prompt?
\Rems
You still have too many command processors. You can drop the whole lot - try
it!
I know,
however it was *intentionally* added --- see my other reply for clarification.

thanks

\Rems

Loading...