Re: CreateProcess not working as doc specifies.




"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









.



Relevant Pages

  • Re: dd command & reading in background
    ... ^ D,"UnixReview: Shell Corner: The dspl Korn Shell ... user input timeout, do a search on C.U.S. for the ... # 0<c<127 - job exited with this exit code ...
    (comp.unix.shell)
  • Re: shell error codes
    ... > I agree to that when a program is launched by the shell. ... The only standardized exit codes are 126 and 127 ... SUS> If the execvefunction fails due to an error equivalent to ... program returned exit code 127 or the command was not ...
    (comp.unix.shell)
  • Re: cant cleanly exit shell from FC5 rescue CD
    ... When I type in 'exit' and hit enter, ... type 'linux rescue' at the prompt and hit ENTER ... at the shell prompt, ...
    (Fedora)
  • funny SIGCHLD behavior
    ... I'm trying to implement a simple shell and am facing some ... SIGCHLD must get sent to the handler. ... to exit. ... * cmdbuf as required by execvfunctions ...
    (comp.unix.programmer)
  • Re: Return Codes from CREATEPROCESS
    ... Or call exit() with that value, ... that typical practice is to have the child process begin execution right ... Depending on the parameters passed to CREATEPROCESS, ... To join/leave the list, search archives, change list settings, * ...
    (comp.sys.hp.mpe)

Loading