Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

NT Batch File: Open app. w/out waiting?

57 views
Skip to first unread message

Harry Potter

unread,
May 26, 2017, 11:08:03 AM5/26/17
to
How do I start a WinNT app from a batch file without waiting until the application exits? Also, how do I perform a file operation from a batch file with the GUI window?

Batchman

unread,
May 26, 2017, 8:45:50 PM5/26/17
to
More details required, particularly with your first question.

Does `GUI window' mean the window you get when you execute Cmd.exe?
What's the file operation you want to perform?

B00ze

unread,
May 26, 2017, 8:59:24 PM5/26/17
to
On 2017-05-26 11:08, Harry Potter <rose.j...@yahoo.com> wrote:

> How do I start a WinNT app from a batch file without waiting until the application exits? Also, how do I perform a file operation from a batch file with the GUI window?

Use START...

ie: START "NULL" /B C:\MyDir\MyProgram.exe bla bla bla

Starts a separate window to run a specified program or command.

START ["title"] [/D path] [/I] [/MIN] [/MAX] [/SEPARATE | /SHARED]
[/LOW | /NORMAL | /HIGH | /REALTIME | /ABOVENORMAL | /BELOWNORMAL]
[/NODE <NUMA node>] [/AFFINITY <hex affinity mask>] [/WAIT] [/B]
[command/program] [parameters]

"title" Title to display in window title bar.
path Starting directory.
B Start application without creating a new window. The
application has ^C handling ignored. Unless the application
enables ^C processing, ^Break is the only way to interrupt
the application.
I The new environment will be the original environment passed
to the cmd.exe and not the current environment.
MIN Start window minimized.
MAX Start window maximized.
SEPARATE Start 16-bit Windows program in separate memory space.
SHARED Start 16-bit Windows program in shared memory space.
LOW Start application in the IDLE priority class.
NORMAL Start application in the NORMAL priority class.
HIGH Start application in the HIGH priority class.
REALTIME Start application in the REALTIME priority class.
ABOVENORMAL Start application in the ABOVENORMAL priority class.
BELOWNORMAL Start application in the BELOWNORMAL priority class.
NODE Specifies the preferred Non-Uniform Memory Architecture
(NUMA)
node as a decimal integer.
AFFINITY Specifies the processor affinity mask as a hexadecimal
number.
The process is restricted to running on these processors.

The affinity mask is interpreted differently when
/AFFINITY and
/NODE are combined. Specify the affinity mask as if
the NUMA
node's processor mask is right shifted to begin at bit
zero.
The process is restricted to running on those processors in
common between the specified affinity mask and the NUMA
node.
If no processors are in common, the process is
restricted to
running on the specified NUMA node.
WAIT Start application and wait for it to terminate.
command/program
If it is an internal cmd command or a batch file then
the command processor is run with the /K switch to cmd.exe.
This means that the window will remain after the command
has been run.

If it is not an internal cmd command or batch file then
it is a program and will run as either a windowed
application
or a console application.

parameters These are the parameters passed to the command/program.

--
! _\|/_ Sylvain / B00...@hotmail.com
! (o o) Member:David-Suzuki-Fdn/EFF/Red+Cross/SPCA/Planetary-Society
oO-( )-Oo It's 95% of the lawyers making the other 5% look bad.

JJ

unread,
May 27, 2017, 4:44:27 AM5/27/17
to
On Fri, 26 May 2017 08:08:02 -0700 (PDT), Harry Potter wrote:
> Also, how do I perform a file operation from a batch file with the GUI window?

If you want to use a file as a parameter to a batch file from Windows
Explorer, create a shortcut file for the batch file and put in into your
profile folder's "SendTo" subfolder.

To use it, right-click a file and choose "Send to", then choose the name of
the shortcut file for that batch file.

JJ

unread,
May 27, 2017, 4:44:27 AM5/27/17
to
On Fri, 26 May 2017 08:08:02 -0700 (PDT), Harry Potter wrote:
> Also, how do I perform a file operation from a batch file with the GUI window?

If you want to use a file as a parameter to a batch file from Windows
Explorer, create a shortcut file for the batch file and put in into your
profile folder's "SendTo" subfolder. In e.g.:

C:\Users\harry\SendTo\

Or...

C:\Users\harry\AppData\Roaming\Microsoft\Windows\SendTo\

JJ

unread,
May 27, 2017, 4:54:44 AM5/27/17
to
Sorry for the double posts. It seems like Albasani server had a delay
glitch.

Harry Potter

unread,
May 27, 2017, 8:05:58 AM5/27/17
to
On Friday, May 26, 2017 at 8:45:50 PM UTC-4, Batchman wrote:
> More details required, particularly with your first question.
>
Okay. Normally, when I run a program from a batch file, the batch file pauses until the program exits. I want the batch file to continue immediately.

> Does `GUI window' mean the window you get when you execute Cmd.exe?
> What's the file operation you want to perform?

When I execute, say, XCOPY from a batch file, it writes messages to the batch file's window. I want to open the window that appears when I copy files from Windows Explorer. I also want to do this from a Win32/64 appliation using the Win32 API from C.

Batchman

unread,
May 27, 2017, 7:37:34 PM5/27/17
to
Harry Potter wrote:

> I want the batch file to continue
> immediately.
Try the EXIT command...
Exits the DOS console or, with /b, only the currently run-
ning batch or the currently executed subroutine. If used
without /b in a batch file, causes the DOS console calling
the batch to close.

> When I execute, say, XCOPY from a batch file, it writes messages to the
> batch file's window.
If you're interested in the messages, you could redirect them to a file then
interpret its contents.
XCOPY *.* \thisfolder > mylogfile.txt

I want to open the window that appears when I copy
> files from Windows Explorer.

I'm not aware that that's possible.

I also want to do this from a Win32/64
> appliation using the Win32 API from C.

Don't speak C but in BASIC you would create your own copy routine by OPENing
each file (in binary mode) and perform a bit copy.

A simpler (dumber) way in BASIC could be to emulate a batch command thus...

SHELL "XCOPY *.* \thisfolder > mylogfile.txt"

The problem with this is it doesn't allow for errors that may occur.



Harry Potter

unread,
May 28, 2017, 9:57:33 AM5/28/17
to
On Saturday, May 27, 2017 at 7:37:34 PM UTC-4, Batchman wrote:
> Harry Potter wrote:
>
> > I want the batch file to continue
> > immediately.
> Try the EXIT command...
> Exits the DOS console or, with /b, only the currently run-
> ning batch or the currently executed subroutine. If used
> without /b in a batch file, causes the DOS console calling
> the batch to close.
>
You misunderstood. I want the batch file to *continue* once a called program starts up rather than wait for the program to exit. In other words, if I have a batch file:

notepad.exe %1
xcopy %2 %temp%\z.txt

I want the xcopy to execute *as soon as* notepad executes, *not* when notepad closes.

> > When I execute, say, XCOPY from a batch file, it writes messages to the
> > batch file's window.
> If you're interested in the messages, you could redirect them to a file then
> interpret its contents.
> XCOPY *.* \thisfolder > mylogfile.txt
>
Again, you misunderstood. I want the batch file display the messages I get from the GUI when I copy a file from Windows Explorer. This is not necessary, though.

> I want to open the window that appears when I copy
> > files from Windows Explorer.
>
> I'm not aware that that's possible.
>
> I also want to do this from a Win32/64
> > appliation using the Win32 API from C.
>
> Don't speak C but in BASIC you would create your own copy routine by OPENing
> each file (in binary mode) and perform a bit copy.
>
> A simpler (dumber) way in BASIC could be to emulate a batch command thus...
>
> SHELL "XCOPY *.* \thisfolder > mylogfile.txt"
>
> The problem with this is it doesn't allow for errors that may occur.

This is not necessary. I'd just like it. :)

Mike Sanders

unread,
May 28, 2017, 5:56:37 PM5/28/17
to
Harry Potter <rose.j...@yahoo.com> wrote:

> I also want to do this from a Win32/64 appliation using the Win32 API from C.

Just a heads up: Consider instead use either API CopyFile()
or MoveFile(), or if you must use a batch file for some
reason, ShellExecute().

Most of theses API calls have [ex]tended variants (CopyFileEx())
that allow for a callback to your handler that act as 'feedback pumps'
providing (for instance) a progress bar to your handler...

Just my 2 cents =)

--
later on,
Mike

https://busybox.hypermart.net

Batchman

unread,
May 28, 2017, 7:18:25 PM5/28/17
to
Harry Potter wrote:

>>
> You misunderstood. I want the batch file to *continue* once a called

>>
> Again, you misunderstood. I want the batch file display the messages I

So now perhaps you might realise why it's important to state CLEARLY what
you are trying to achieve?

Kerr Mudd-John

unread,
May 29, 2017, 3:06:05 PM5/29/17
to
On Sat, 27 May 2017 01:59:16 +0100, B00ze <B00...@hotmail.com> wrote:

> On 2017-05-26 11:08, Harry Potter <rose.j...@yahoo.com> wrote:
>
>> How do I start a WinNT app from a batch file without waiting until the
>> application exits? Also, how do I perform a file operation from a
>> batch file with the GUI window?
>
> Use START...
>
> ie: START "NULL" /B C:\MyDir\MyProgram.exe bla bla bla

Yup, newbies (I've been there!) often miss out the vital but pointless
"string" title.
[]

--
Bah, and indeed, Humbug

Todd Vargo

unread,
May 31, 2017, 12:08:24 AM5/31/17
to
On 5/28/2017 9:57 AM, Harry Potter wrote:
> On Saturday, May 27, 2017 at 7:37:34 PM UTC-4, Batchman wrote:
>> Harry Potter wrote:
>>
>>> I want the batch file to continue
>>> immediately.
>> Try the EXIT command...
>> Exits the DOS console or, with /b, only the currently run-
>> ning batch or the currently executed subroutine. If used
>> without /b in a batch file, causes the DOS console calling
>> the batch to close.
>>
> You misunderstood. I want the batch file to *continue* once a called program starts up rather than wait for the program to exit. In other words, if I have a batch file:
>
> notepad.exe %1
> xcopy %2 %temp%\z.txt
>
> I want the xcopy to execute *as soon as* notepad executes, *not* when notepad closes.

START "" notepad.exe %1


--
Todd Vargo
(Post questions to group only.)

Harry Potter

unread,
May 31, 2017, 8:03:29 AM5/31/17
to
So I use START. Thanks! :)

Tom Del Rosso

unread,
Jun 4, 2017, 3:17:25 PM6/4/17
to
FWIW, it was clear to me in both of his first 2 posts.



Tom Del Rosso

unread,
Jun 4, 2017, 3:18:49 PM6/4/17
to
FWIW, it was clear to me in both of his first 2 posts.

...Although the second part of his question wasn't clear to me.



0 new messages