in reply to Re: Perl Directive
in thread Perl Directive

One supposes this means that using system in a Perl script to call up a document will not launch the associated application.

No, it will. The behavior I observe is that it will first try to start the file as a program (CreateProcess), and if that fails to work, then try again with file associations (ShellExecute). You only see this when you have a exe file renamed to something like html. Perl will execute the program like an exe file, but clicking on it will start your web browser and display the binary data. However, if you have a html file with html actually in it, Perl will start the web browser on it too. This might create a security hole if a program is running system($filename) on untrusted files. So don't do that.

Out of curiousity, what if you rename an EXE with a .bat extension and double-click it?

.bat files are actually text files which are input to cmd.exe. So if you do this, you will start up a cmd.exe and try to feed the binary data into it, which will not work very well.

Replies are listed 'Best First'.
Re: Perl Directive
by jonadab (Parson) on Dec 15, 2004 at 01:05 UTC
    .bat files are actually text files which are input to cmd.exe

    Yeah, I know what they *are*. (I cut my teeth on PC-DOS 3.3, so I've written a couple of batch files. I once joked about writing interactive fiction as a series of DOS3 batch files for an abuse-of-language contest. Of course, Zarf's threat to do one in PostScript was a bit more impressive...) But the registry assocation that Explorer uses is set up (at least in Win9x/Me, by default) exactly the same way as for EXE files:

    @="\"%1\" %*"

    That is, they're directly executable. And there's obviously no magic number in them— they don't even have to have the trailing ^Z (EOF) any more in Windows. So I was wondering how the API can determine that they're batch files, if not by looking at the extension _again_ after Explorer has handed off to CreateProcess.

    "In adjectives, with the addition of inflectional endings, a changeable long vowel (Qamets or Tsere) in an open, propretonic syllable will reduce to Vocal Shewa. This type of change occurs when the open, pretonic syllable of the masculine singular adjective becomes propretonic with the addition of inflectional endings."  — Pratico & Van Pelt, BBHG, p68