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!
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)
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
OOPS, sorry Michael, seems you posted while I was typing. Your words state it perfectly.
Paul
Thankyou for the replies both :U
Now, when debugging, I get ERROR_NOACCESS :red
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.)
'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.
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)
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