Execfile and Vista

Blitz3D Forums/Blitz3D Programming/Execfile and Vista

RifRaf(Posted 2009) [#1]
	 ExecFile("TINYTANK_CLIENTUPDATE.EXE")
	 End

Im having some issues with this. In XP it works as I expect it to, the app closes and runs the updater, wich if needed creates relpaces the exe of the app that had just closed.


In vista however, the main exe window dissapears, but is still in the processs list, and when the updater tries to overwrite the old exe, it fails with a stream error.

Any idea how to have vista behave like XP in this scenario.

Any help is appreciated.
Thanks


EDIT: well ive gotten a report this can happen on XP too. Hm.


Warner(Posted 2009) [#2]
It looks as if it waits for the executed file to close. I think it has to do with threads/rights. So I think you need to use an API call to do this.
CreateProcess could be a good start, although it might as well be the same call that ExecFile uses:
http://msdn.microsoft.com/en-us/library/ms682425(VS.85).aspx
But calling it yourself might allow for setting other flags.
The decls for api_createprocess are here:
http://www.blitzmax.com/codearcs/codearcs.php?code=1180


RifRaf(Posted 2009) [#3]
@Warner , yes the api call createprocess() does stop the execution of the root program until the called program has completed.

However, I think I got it.. for anyone elses benefit here is the solution I found.

Using Shell32.DLL found on all the windows operating systems I have. XP and Vista.

Decls

.lib "Shell32.dll"

ShellExecuteA(hwnd%,op$,file$,params$,dir$,showcmd%)


when your game is ready to launch another exe and end you call it like this
; at the top of your program you have to record the window handle
Global hwnd%=SystemProperty("apphwnd")

;later when you are exiting
ShellExecuteA(hwnd%,"open","whatever.Exe","","",1)
End


edit : the last parameter indicates how the new window will behave. 1 and 9 bring it to top and max size, 0 hides it.. even from the process window. 2-8 do stuff too but I forgot what.


Warner(Posted 2009) [#4]
Ah, that is nice. Glad you solved it.


Wings(Posted 2009) [#5]
RifRaf this is verry usefull... i had almost given up patch support in vista.