News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

WinExec problem

Started by brixton, December 23, 2005, 04:26:49 PM

Previous topic - Next topic

brixton

OK, I am writing a program which has to create a batch file (just using a filename, no path, so the file is written in the current directory), but when I _lclose it after writing, and then invoke WinExec, ADDR filename, I always get ''filename.bat' is not recognized as an internal or external command, operable program or batch file.'.  This is a load of crap as the .bat IS created successfully and IS in the directory of the calling process..  So I can't see why it doesn't find it successfully.

Any help?  Is this a common problem?  I tried moving all the files to the root directory and it didn't affect it.

Thanks in advance!
If you love somebody, set them free.
If they return, they were always yours. If they don't, they never were..

P1

Read your documentation !!!

Include your full path.

And after you read the documentation on WinExec ( Hint: It uses CreateProcess ), then you will know that it should have been passed with a "cmd.exe" for NT and "command.com" for the Dos OSes.

For better programming:
Remarks

Win32-based applications should use the CreateProcess function rather than this function. The WinExec function exists in Win32 to provide compatibility with earlier versions of Windows. For more information about how the WinExec function is implemented, see the Remarks section of the LoadModule function.


Regards,  P1  :8)

PBrennick

The batch file needs to be the tail portion of CreateProcess and cmd.exe or command.com is the executable.  The default directory for READ and for WRITE are not guaranteed to be the same so use the FULL path.

Paul
The GeneSys Project is available from:
The Repository or My crappy website

PBrennick

OOPS, sorry Michael, seems you posted while I was typing.  Your words state it perfectly.

Paul
The GeneSys Project is available from:
The Repository or My crappy website

brixton

Thankyou for the replies both  :U
If you love somebody, set them free.
If they return, they were always yours. If they don't, they never were..

brixton

Now, when debugging, I get ERROR_NOACCESS  :red
If you love somebody, set them free.
If they return, they were always yours. If they don't, they never were..

tenkey

Add the /c option to command.exe or cmd.exe to get a program to run. Use command.exe only on Win9x systems (includes ME). On all others use cmd.exe.

command.exe /c app.exe arglist
cmd.exe /c app.exe arglist

The /c will also handle batch files and the commands that aren't handled by executables (like DIR, DEL, REN, etc.)
A programming language is low level when its programs require attention to the irrelevant.
Alan Perlis, Epigram #8

zooba

'COMMAND.COM' does exist on post-9x systems, but it is much slower. Depending on what your batch file needs to do, you may be able to get away with using command.com exclusively.

P1

Quote from: brixton on December 25, 2005, 02:02:09 AM
Now, when debugging, I get ERROR_NOACCESS  :red
Post some code, I know you are using something wrong!

Regards,  P1  :8)

brixton

Hey P1,

Yeah, to be honest I couldn't find the mistakes..
So I copy/pasted the algos I needed and just re-wrote everything else.  I didn't even use cmd.exe or command.com or anything, just WinExec'd the batchfile and it works now.  I think maybe I had errors previously messing everything up.. But I still don't know where they are lol  :bg
If you love somebody, set them free.
If they return, they were always yours. If they don't, they never were..