Monday, August 10, 2009

Using system commands in perl executable causes console window to popup

After converting a perl program to an executable file using perl2exe or pp (PAR Packer) under windows I had a problem arise.
I was using a system call to print an html file from a tkx based perl program.
All was great until I tried to compile with the -gui command in order to prevent the console window from showing while processing the program.
Which worked well except when the user initiated a print job.
A console window would popup and would not go away until the user clicked ok in the print dialog.
After hours of searching I found this solution, very simple, just add the following code to the perl script and recompile to exe.


Win32::SetChildShowWindow(0) if defined &Win32::SetChildShowWindow;



See the source for this solution here.

Thanks Activestate!

No comments:

Post a Comment