freeprocess.bmx/.c

BlitzMax Forums/BlitzMax Programming/freeprocess.bmx/.c

Eternal Crisis(Posted 2012) [#1]
Is there a way to stop this from using ".exe" at the end? I can't seem to get this to work, not matter what I do, it adds ".exe" at the end when creating a process. Unless I'm missing something.

If I create process through Extern "Win32" I can get it to NOT add ".exe" at the end.

Hopefully what I'm asking isn't confusing but I'm just lost.


Eternal Crisis(Posted 2012) [#2]
I decided to just use batch files, but it just feels so wrong, lol. I hate no being able to figure something out due to my lack of C knowledge and/or C with BMax.

Basically, my situation was that if "Application.exe flag" was executed, it would open another window. So I needed to execute "Application flag" to stop that from happening.

Using "CreateProcess" or "CreateProcessA" manually I was able to achieve this but I couldn't manipulate freeprocess.c/.bmx enough to replicate. I also needed the streaming to print out the results.

If anyone knows how that do that and could help out it would be appreciated. Not only as a learning experience but then I can dump the batch file method.

Thanks.


skidracer(Posted 2012) [#3]
You need to post some code I think, or rethink your belief that including the .exe suffix is having any effect.

btw FreeProcess uses the lpCommandLine argument, not the lpApplicationName argument, both are documented here:

http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx


Eternal Crisis(Posted 2012) [#4]
It does have an effect, at least from testing, even while in command prompt. I'm building an editor for use with UE3. In command prompt if I type: "MyGame.exe make" it will open another command prompt window (I'm sure this is all due to how UE3 works as well). If I type: "MyGame make" it will execute the command and stay within the current command prompt window.

This was also happening when creating a processes, it would open a command prompt, execute "MyGame.exe make" and open another command prompt (which never shows up but it's running according to my processes list). No matter what I provide to CreateProcess the ".exe" is added after "MyGame."

I've looked over freeprocess.c and I couldn't see anywhere that ".exe" is being added manually, so I'm guessing the C version of CreateProcess does this automatically? I'm not good enough in C to know exactly what's going on in there, lol.

I have also read the page you linked shortly after I posted this thread when attempting to search a solution. If I was to make an Extern that uses CreateProcess or CreateProcessA the ".exe" is not added, and it executes exactly what I want. But, that's about all I know. I would post code but I'm using it at it should be:

local process:TProcess = CreateProcess(MyDirectory+"\MyGame make", 0)

I've tried quoting, I've tried quoting just the executable - just the make - both, I've tried not quoting, I've tried full path into process, I've tried changing directory and using local path or direct, I've tried hiding console and not, and so on. No matter what ".exe" is added to the end of "MyGame."

Thanks for replying, skidracer, greatly appreciated.


skidracer(Posted 2012) [#5]
It sounds like you have two builds of your game, one with option "gui app" disabled. But you might be right about the .exe thing [shrug].

FYI you should also quote your path in case there are spaces.

local cmdline$="~q"+MyDirectory+"\MyGame"+"~q make"
local process:TProcess = CreateProcess( cmdline, 0)


Eternal Crisis(Posted 2012) [#6]
Yeah, I did quoted, not quoted, quoted in different ways and the final version is quoted in a batch file. In the batch file I'm able to run without ".exe" so it stays within the same command prompt instead of opening a new prompt.

Well, you know, I wish I was wrong because then there would be a right, lol. It would have been nice to use createprocess directly instead of using a batch file in the background. Not a huge deal though I guess.

Thanks for taking the time to help, skidracer.