Re: CreateProcess not working as doc specifies.
- From: "Hector Santos" <nospamhere@xxxxxxxxxxxxxx>
- Date: Wed, 15 Jun 2005 05:30:43 -0400
"David Bennion" <DavidBennion@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:46C32BDF-19DB-472F-922E-763C3D18EBB8@xxxxxxxxxxxxxxxx
>
> So the exit code is able to be correctly retrieved. It just appears not
to
> be properly maintained running through cmd.exe.
It really depends on the OS. Have you looked at the EXIT command? Type
HELP EXIT for help.
This should work:
--- MybatchFile.cmd---
@echo off
mydummyapp.exe
exit %errorlevel%
> In what ways is ShellExecuteEx different in the way it would run a batch
file?
First, the proper way to run a shell, is to use the comspec
char *pszComSpec := getenv("comspec");
In short, this will tell you if you are using 95-based command.com shells or
NT-based cmd.exe shells.
Second, a smart wrapper for CreateProcess() will consider shell vs spawns.
A shell is when you use the comspec as the image. A spawn is when you go
direct with image (ie. EXE, COM). So when using the comspec, you are
spawning CMD.EXE to run a script file for you (batch) files. It is not
necessary for natural images, like EXE and COM files.
ShellExecuteXX() is mostly designed to be used with File Associations, I
mean, that is were it serves best. Think of CreateProcess as the raw low
level mention and ShellExecuteXX() as being "Explorer" with short cuts. <g>
In short, how I basically remember how to use this stuff when I need it
over the years is when dealing with CreateProcess, if you want the system
to figure it for you, then use use the lpCommandLine with lpApplicationName
as NULL.
CreateProcess(NULL,"myapplet.exe",,,,)
Win32 will follow the PATH to see if it can find it because what it
basically does is RUN a shell for you.
But if you know for sure the fully qualiied path name, then you use the
first parameter, with the parameters in second.
Hope this helps
--
Hector Santos, Santronics Software, Inc.
http://www.santronics.com
.
- References:
- CreateProcess not working as doc specifies.
- From: David Bennion
- Re: CreateProcess not working as doc specifies.
- From: Walter Briscoe
- Re: CreateProcess not working as doc specifies.
- From: David Bennion
- Re: CreateProcess not working as doc specifies.
- From: Gary Chanson
- Re: CreateProcess not working as doc specifies.
- From: David Bennion
- CreateProcess not working as doc specifies.
- Prev by Date: Re: CreateProcess not working as doc specifies.
- Next by Date: Where to begin kernel programming?
- Previous by thread: Re: CreateProcess not working as doc specifies.
- Next by thread: Re: CreateProcess not working as doc specifies.
- Index(es):
Relevant Pages
|
Loading