chessgui has asked for the wisdom of the Perl Monks concerning the following question:

I know all too well that if I want to run a Tk app under Windows without the annoying dos window being opened I need to run it via wperl.exe rather than perl.exe.

This works fine as far as the Tk app itself does not open an other process as a pipe. If it does so not only a dos window is opened for that process but the Tk app itself crashes(!).

Any thoughts on that? ( Are there alternative ways to get rid of such a dos window? )
  • Comment on Wperl.exe fails with Tk + piped process ( Win32 )

Replies are listed 'Best First'.
Re: Wperl.exe fails with Tk + piped process ( Win32 )
by Anonymous Monk on Jan 09, 2012 at 11:05 UTC

    show code

    hide dos windows

    BEGIN { Win32::SetChildShowWindow(0) if defined &Win32::SetChildShowWindow +; }

    Or hide on a per process basis use Win32::Process

      If I use SetChildShowWindow(SW_HIDE) wperl.exe won't open the console window for the piped process but the app itself crashes anyway (in fact NO code following the Open2 seems to be processed - it simply freezes at that point). Your second solution won't work since $cflags (creation flags, like CREATE_NO_WINDOW) can only be passed to a Win32::Process object if the process is created by Win32::Process::Create. If you create a process from a pid through Win32::Process::Open $cflags can not be passed (therefore you can't shut down a window created by Open2 or the window of the script itself).

      Let's put it simply: wperl.exe crashes with an Open2 call under Win32, perl.exe on the other hand always opens a console window whether there are child processes or not.

        wperl.exe won't open the console window for the piped process but the app itself crashes anyway

        So you say again :) Maybe you'd like to prove it by posting some code?