Nixing the DOS/Command Window under Windows ? 
Author Message
 Nixing the DOS/Command Window under Windows ?

I currently have the *.pl extension mapped to the action:

 "C:\Perl\binperl.exe" "%1" %*

in the Explorer/Tools/Folder Options/File Types/Advanced setting for PERL.
This means I can double click a random foo.pl Tk script and have it run. The
problem is that there is also a superfluous DOS/Command Window that sits
around, presumably the parent of the perl process. Is there someway of not
getting this extra window?

-Mark

Mark Lakata, Staff Engineer    1225 Charleston Road       voice 650-567-5170
MIPS Technologies              Mountain View CA 94043     fax   650-567-5002

-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server.  If you wish to unsubscribe from this mailing list, send the



Sun, 19 Sep 2004 04:48:20 GMT  
 Nixing the DOS/Command Window under Windows ?
In the source Perl/Tk distribution, there was/is a way to build the perl
executable as a Windows GUI app rather than a console app. The resulting
executable was named guiperl.exe. I have used it successfully in the exact
manner you are describing but I don't know if the build still creates it.
ActivePerl doesn't have it in the binary distribution even though Perl/Tk is
included with it. To build it yourself, you'll need Visual C/C++

Damion K. Wilson


Quote:
> I currently have the *.pl extension mapped to the action:

>  "C:\Perl\binperl.exe" "%1" %*

> in the Explorer/Tools/Folder Options/File Types/Advanced setting for PERL.
> This means I can double click a random foo.pl Tk script and have it run.
> The problem is that there is also a superfluous DOS/Command Window that
> sits around, presumably the parent of the perl process. Is there someway of
> not getting this extra window?

> -Mark

> Mark Lakata, Staff Engineer    1225 Charleston Road       voice
> 650-567-5170 MIPS Technologies              Mountain View CA 94043     fax
>  650-567-5002

> -++**==--++**==--++**==--++**==--++**==--++**==--++**==
> This message was posted through the Stanford campus mailing list
> server.  If you wish to unsubscribe from this mailing list, send the


-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server.  If you wish to unsubscribe from this mailing list, send the



Sun, 19 Sep 2004 06:02:34 GMT  
 Nixing the DOS/Command Window under Windows ?
I found this originally on www.perltk.org .
Just add these two lines in your code:

use Win32::Console;
Win32::Console::Free;

Hope this is what your looking for.

-Chuck

Quote:
----- Original Message -----


Sent: Tuesday, April 02, 2002 11:49 AM
Subject: Nixing the DOS/Command Window under Windows ?

> I currently have the *.pl extension mapped to the action:

>  "C:\Perl\binperl.exe" "%1" %*

> in the Explorer/Tools/Folder Options/File Types/Advanced setting for PERL.
> This means I can double click a random foo.pl Tk script and have it run.
The
> problem is that there is also a superfluous DOS/Command Window that sits
> around, presumably the parent of the perl process. Is there someway of not
> getting this extra window?

> -Mark

> Mark Lakata, Staff Engineer    1225 Charleston Road       voice
650-567-5170
> MIPS Technologies              Mountain View CA 94043     fax
650-567-5002

> -++**==--++**==--++**==--++**==--++**==--++**==--++**==
> This message was posted through the Stanford campus mailing list
> server.  If you wish to unsubscribe from this mailing list, send the


-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server.  If you wish to unsubscribe from this mailing list, send the



Sun, 19 Sep 2004 06:42:30 GMT  
 Nixing the DOS/Command Window under Windows ?
Thanks. I had to customize this snippet to cooperate with other OS'es:

if ($^O eq "MSWin32") {
  require Win32::Console;
  Win32::Console::Free();

Quote:
}

note addition of if() clause, use -> require, and () appended to Free.

This seems to work under solaris as well as MSWin32 ...

(The whole reason for this silly applet is for me to be able to Copy something
on my Windows machine and paste it somewhere on my Solaris machine... the two
machines (and monitors) sit inches apart on my desk top, and it seemed just
natural that I should be able to copy something with the right-hand mouse and
paste it with the left-hand mouse (and vice-versa)! )

-Mark

Mark Lakata, Staff Engineer    1225 Charleston Road       voice 650-567-5170
MIPS Technologies              Mountain View CA 94043     fax   650-567-5002

Quote:

> I found this originally on www.perltk.org .
> Just add these two lines in your code:

> use Win32::Console;
> Win32::Console::Free;

> Hope this is what your looking for.

> -Chuck

> ----- Original Message -----


> Sent: Tuesday, April 02, 2002 11:49 AM
> Subject: Nixing the DOS/Command Window under Windows ?

> > I currently have the *.pl extension mapped to the action:

> >  "C:\Perl\binperl.exe" "%1" %*

> > in the Explorer/Tools/Folder Options/File Types/Advanced setting for PERL.
> > This means I can double click a random foo.pl Tk script and have it run.
> The
> > problem is that there is also a superfluous DOS/Command Window that sits
> > around, presumably the parent of the perl process. Is there someway of not
> > getting this extra window?

> > -Mark

> > Mark Lakata, Staff Engineer    1225 Charleston Road       voice
> 650-567-5170
> > MIPS Technologies              Mountain View CA 94043     fax
> 650-567-5002

> > -++**==--++**==--++**==--++**==--++**==--++**==--++**==
> > This message was posted through the Stanford campus mailing list
> > server.  If you wish to unsubscribe from this mailing list, send the


-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server.  If you wish to unsubscribe from this mailing list, send the



Sun, 19 Sep 2004 07:10:30 GMT  
 Nixing the DOS/Command Window under Windows ?

Quote:

> In the source Perl/Tk distribution, there was/is a way to build the perl
> executable as a Windows GUI app rather than a console app. The resulting
> executable was named guiperl.exe. I have used it successfully in the exact
> manner you are describing but I don't know if the build still creates it.
> ActivePerl doesn't have it in the binary distribution even though Perl/Tk is
> included with it. To build it yourself, you'll need Visual C/C++

If I remember right, the new versions of perl have it as wperl.exe

--

Anderson CAD/CAM, Inc           Lucifer designed MS-DOS to try
3800 Apache Lane NE                 men's souls.
St Anthony, MN  55421           Then he had a better idea...
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server.  If you wish to unsubscribe from this mailing list, send the



Sun, 19 Sep 2004 07:11:21 GMT  
 Nixing the DOS/Command Window under Windows ?
Mark

Win32 executables typically run in either of two subsystems: the
GUI subsystem or the CUI (console) subsystem.  CUI applications
have a console window, either inherited from their parent (for
example, when starting perl.exe from cmd.exe, perl.exe will inherit
the console from cmd.exe), or (if the parent has none), the
system will create a console automatically.

What you are seeing is not a DOS/Command window, but actually the
console created by Windows for perl.exe; in this case, explorer.exe
is the parent of perl.exe.

Sadly, there is no easy way to tell Windows that you don't want it
to create a console when you run your console app from Explorer.
(There has been much discussion on this on various lists---a quick
google search on windows+console+cui+gui will return many hits.)

What you can do is create a copy of perl.exe named (e.g.) guiperl.exe,
and hack it to change the subsystem indicator byte from CUI to GUI.
That way Windows won't create the disfiguring console window when
you run it.  That's what I do.

Hopefully I won't upset too many people on the list with the "short"
Perl script I use to make this change.  There are probably other,
better, ways to do this.

Finally, note that you can't have it both ways: if you convert a
CUI app to GUI and run it from the command line, you won't see any
output (you can try this with, e.g. ping.exe as well as guiperl -v).
If you use a CUI app, you will get the hideous black box even if
you don't want it.

This may affect you since you use shortcuts to run your Perl
scripts.

Hope this helps

Tom Cosgrove
London, UK

---snip---
# gui.pl -- Convert a Win32 EXE to use GUI subsystem
#
use strict ;

my $usage = "$0: usage: perl $0 <EXE file> GUI | CUI\n" ;

my $file = shift || die($usage) ;

# What sub-system was requested?
#
my $ss_req = shift || die($usage) ;
my ($ss_name, $ss_id) ;

if ( $ss_req =~ /^c/i )                 # Character mode (CUI)
{
  ($ss_name, $ss_id) = ("CUI", 3) ;

Quote:
}

elsif ( $ss_req =~ /^g/i )              # GUI
{
  ($ss_name, $ss_id) = ("GUI", 2) ;
Quote:
}

else
{
  die($usage) ;

Quote:
}

open(EXE, "<$file") || die("$0: unable to open input file $file\n") ;
binmode(EXE) ;
undef $/ ;
my $data = <EXE> ;
close(EXE) ;

my $dos = "a2" .                        # MZ
          "v" .                         # WORD bytes in last page of file
          "v" .                         # WORD pages in file
          "v" .                         # WORD relocations
          "v" .                         # WORD paras in header
          "v" .                         # WORD min extra paras needed
          "v" .                         # WORD max extra paras needed
          "v" .                         # WORD initial SS value
          "v" .                         # WORD initial (relative) SP value
          "v" .                         # WORD checksum
          "v" .                         # WORD initial IP
          "v" .                         # WORD initial (relative) CS
          "v" .                         # WORD file address of reloc table
          "v" .                         # WORD overlay number
          "x8" .                        # WORD reserved
          "v" .                         # WORD OEM ID
          "v" .                         # WORD OEM info
          "x20" .                       # WORD reserved
          "V" ;                         # LONG file address of new EXE header


my $pe_offset = $dos[16] ;

my $pe = "x$pe_offset" .                # Skip to new PE header
         "a2x2" .                       #       PE \0 \0
         "v" .                          #  WORD machine
         "v" .                          #  WORD no. of sections
         "V" .                          # DWORD date/time stamp
         "V" .                          # DWORD ptr to symbol table
         "V" .                          # DWORD no. of symbols
         "v" .                          #  WORD size of optional header
         "v" ;                          #  WORD characteristics

my $opt_offset = $pe_offset + 24 ;
my $opt = "x$opt_offset" .              # Skip to optional header
          "v" .                         #  WORD magic
          "C" .                         #  BYTE major linker version
          "C" .                         #  BYTE minor linker version
          "V" .                         # DWORD size of code
          "V" .                         # DWORD size of init'ed data
          "V" .                         # DWORD size of un-init'ed data
          "V" .                         # DWORD RVA (rel. addr.) of entry point
          "V" .                         # DWORD RVA of base of code
          "V" .                         # DWORD RVA of base of data
          "V" .                         # DWORD image base
          "V" .                         # DWORD section alignment
          "V" .                         # DWORD file alignment
          "v" .                         #  WORD major OS version
          "v" .                         #  WORD minor OS version
          "v" .                         #  WORD major image version
          "v" .                         #  WORD minor image version
          "v" .                         #  WORD major subsystem version
          "v" .                         #  WORD minor subsystem version
          "x4" .                        # DWORD reserved
          "V" .                         # DWORD size of image
          "V" .                         # DWORD size of headers
          "V" .                         # DWORD checksum (yeah, right)
          "V" ;                         #  WORD subsystem
                                        # ... and then we lose interest


# print sprintf("0x%X", $pe2[0]), "  ", $pe2[21], "\n" ;

my $sub_offset = $pe_offset + 24 + 68 ;

my $ss_orig = ord(substr($data, $sub_offset, 1)) ;

if ( $ss_orig == $ss_id )
{
  print "$file is already a $ss_name app\n" ;

Quote:
}

else
{
  substr($data, $sub_offset, 1) = chr($ss_id) ;

  print "$file patched to be a $ss_name app ($ss_orig => $ss_id)\n" ;

  open(EXE, ">$file") || die("$0: unable to open output file $file\n") ;
  binmode(EXE) ;
  print EXE $data ;
  close(EXE) ;

Quote:
}

---snip---

Quote:
>>> Mark Lakata 2-Apr-02 20:49 >>>

I currently have the *.pl extension mapped to the action:

 "C:\Perl\binperl.exe" "%1" %*

in the Explorer/Tools/Folder Options/File Types/Advanced setting for PERL.
This means I can double click a random foo.pl Tk script and have it run. The
problem is that there is also a superfluous DOS/Command Window that sits
around, presumably the parent of the perl process. Is there someway of not
getting this extra window?

-Mark

Mark Lakata, Staff Engineer    1225 Charleston Road       voice 650-567-5170
MIPS Technologies              Mountain View CA 94043     fax   650-567-5002


Date: Tue, 2 Apr 2002 23:44:58 +0100 (BST)


Subject: Re: Nixing the DOS/Command Window under Windows ?


Quote:
>>> Tom Cosgrove 2-Apr-02 23:17 >>>

Mark

Win32 executables typically run in either of two subsystems: the
GUI subsystem or the CUI (console) subsystem.  CUI applications
have a console window, either inherited from their parent (for
example, when starting perl.exe from cmd.exe, perl.exe will inherit
the console from cmd.exe), or (if the parent has none), the
system will create a console automatically.

What you are seeing is not a DOS/Command window, but actually the
console created by Windows for perl.exe; in this case, explorer.exe
is the parent of perl.exe.

Sadly, there is no easy way to tell Windows that you don't want it
to create a console when you run your console app from Explorer.
(There has been much discussion on this on various lists---a quick
google search on windows+console+cui+gui will return many hits.)

What you can do is create a copy of perl.exe named (e.g.) guiperl.exe,
and hack it to change the subsystem indicator byte from CUI to GUI.
That way Windows won't create the disfiguring console window when
you run it.  That's what I do.

Hopefully I won't upset too many people on the list with the "short"
Perl script I use to make this change.  There are probably other,
better, ways to do this.

Hope this helps

Tom Cosgrove
London, UK

---snip---
# gui.pl -- Convert a Win32 EXE to use GUI subsystem
#
use strict ;

my $usage = "$0: usage: perl $0 <EXE file> GUI | CUI\n" ;

my $file = shift || die($usage) ;

# What sub-system was requested?
#
my $ss_req = shift || die($usage) ;
my ($ss_name, $ss_id) ;

if ( $ss_req =~ /^c/i )                 # Character mode (CUI)
{
  ($ss_name, $ss_id) = ("CUI", 3) ;

Quote:
}

elsif ( $ss_req =~ /^g/i )              # GUI
{
  ($ss_name, $ss_id) = ("GUI", 2) ;
Quote:
}

else
{
  die($usage) ;

Quote:
}

open(EXE, "<$file") || die("$0: unable to open input file $file\n") ;
binmode(EXE) ;
undef $/ ;
my $data = <EXE> ;
close(EXE) ;

my $dos = "a2" .                        # MZ
          "v" .                         # WORD bytes in last page of file
          "v" .                         # WORD pages in file
          "v" .                         # WORD relocations
          "v" .                         # WORD paras in header
          "v" .                         # WORD min extra paras needed
          "v" .                         # WORD max extra paras needed
          "v" .                         # WORD initial SS value
          "v" .                         # WORD initial (relative) SP value
          "v" .                         # WORD checksum
          "v" .                         # WORD initial IP
          "v" .                         # WORD initial (relative) CS
          "v" .                         # WORD file
...

read more »



Sun, 19 Sep 2004 07:42:21 GMT  
 Nixing the DOS/Command Window under Windows ?

Quote:
> I currently have the *.pl extension mapped to the action:

>  "C:\Perl\binperl.exe" "%1" %*

Try "C:\Perl\bin\wperl.exe" "%1" %*

Chris Eustace.



Sun, 19 Sep 2004 09:07:52 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Nixing the DOS/Command Window under Windows ?

2. More Re: Nixing the DOS/Command Window under Windows ? (fwd)

3. More Re: Nixing the DOS/Command Window under Windows ? (fwd)

4. Perl command line processing, Windows/dos style ?

5. UNIX fix_cr command exits something in DOS / Windows ?

6. Minimizing DOS Window on ActivePerl 6.23 under Windows ME

7. DOS big perl crash under MS/Windows

8. . Informix Perl on DOS/Windows Platform

9. Socket support for DOS/Windows bigperl

10. ??Where Perl for DOS/Windows?

11. Perl for Windows & DOS

12. PERL for DOS/Windows?

 

 
Powered by phpBB® Forum Software