I'm not sure how to takle debugging this. I have a largish program which as one of its functions will accept a users command and issue it via SHELL. What I am seeing is that it is only working while running in the PowerBasic IDE, it does NOT run from the compiled EXE file.
So I extract the small bit of code which does the shell to a test program. It functions perfectly within the IDE, but it ALSO runs fine as a compiled EXE.
What I see when it fails is the briefest flash of a DOS window for just an instant.
Here's the small test pgm.
and here's the tiny BAT file I'm testing with.
So -- the test program works both IN the IDE and as a compiled EXE.
The same code in the main program works fine in the IDE, but not in the compiled EXE.
Any ideas what the difference is? The main program does have 1 dialog window open when it does the SHELL, the little test program does not.
Displaying ERR always shows no error occurred. Note the test program has both SHELL and CreateProcess. They BOTH work fine.
They also both work fine in the full program within the IDE, but not from the EXE.
????? I've gotta be missing something real simple here.
George
So I extract the small bit of code which does the shell to a test program. It functions perfectly within the IDE, but it ALSO runs fine as a compiled EXE.
What I see when it fails is the briefest flash of a DOS window for just an instant.
Here's the small test pgm.
Code:
#COMPILE EXE #DIM ALL #INCLUDE "Win32Api.inc" FUNCTION PBMAIN () AS LONG LOCAL lclCmd AS ASCIZ * 100 LOCAL rcProcess AS PROCESS_INFORMATION LOCAL rcStart AS STARTUPINFO LOCAL RetC AS LONG lclCmd = ENVIRON$("COMSPEC") + " /C " + "TestBatch.BAT Operand1 Operand2" ' Setup command rcStart.cb = LEN(rcStart) ' Initialize the STARTUPINFO structure: ' Try using the SHELL function RetC = SHELL(lclCmd,1) ' Try using CreateProcess RetC = CreateProcess(BYVAL %NULL, BYCOPY lclCmd, BYVAL %NULL, BYVAL %NULL, 1&, _ %CREATE_NEW_CONSOLE OR %NORMAL_PRIORITY_CLASS, BYVAL %NULL, _ BYVAL %NULL, rcStart, rcProcess) CALL CloseHandle(rcProcess.hThread) CALL CloseHandle(rcProcess.hProcess) END FUNCTION
Code:
@echo off Echo Starting batch file echo Parameter One is %1 echo Parameter Two is %2 echo End of batch file pause
The same code in the main program works fine in the IDE, but not in the compiled EXE.
Any ideas what the difference is? The main program does have 1 dialog window open when it does the SHELL, the little test program does not.
Displaying ERR always shows no error occurred. Note the test program has both SHELL and CreateProcess. They BOTH work fine.
They also both work fine in the full program within the IDE, but not from the EXE.
????? I've gotta be missing something real simple here.
George
Comment