in reply to Re^2: Wperl.exe fails with Tk + piped process ( Win32 )
in thread Wperl.exe fails with Tk + piped process ( Win32 )

How to hide/inhibit the console window when launching a Perl script on Windows?
  • Comment on Re^3: Wperl.exe fails with Tk + piped process ( Win32 )

Replies are listed 'Best First'.
Re^4: Wperl.exe fails with Tk + piped process ( Win32 )
by chessgui (Scribe) on Jan 10, 2012 at 10:43 UTC
    Now this post has been useful. Thanks a lot.

    Unfortunately I could not test the Win32::GUI solution (since I can't build Win32::GUI due to make errors), but luckily there is an example code which does the same in slightly more complicated way by using Win32::API (which installs on my system seamlessly).

    This latter code works for me after some massaging. Though the consolde window is created but is shut down immediately.

    Thanks again, this is a perfect solution.

      You know, its trivial to create a tiny gui win32 .exe, which sets up all the console hiding stuff, and then launches a hidden perl.exe as opposed to wperl.exe

      or you could simply use wperl.exe , call the hiding children function, then launch a hidden perl.exe

        It works! You only have to take care to create the Win32::Process object with creation flag: CREATE_NO_WINDOW.

        I copy the code should anyone need it.

        So, run this script via wperl.exe from the working directory of the main script (let's say that the path to perl.exe is 'c:\strawberry\perl\bin' and the main script is called 'gui.pl'):

        use Win32::Process; Win32::Process::Create($perl,'c:\strawberry\perl\bin\perl.exe','perl.e +xe gui.pl',0,CREATE_NO_WINDOW,'.');


        In the main script include:

        use Win32 qw(SW_HIDE); Win32::SetChildShowWindow(SW_HIDE);


        In this framework no console window is opened and the Open2 call is safe.