How do I make Perl scripts recognize parameters in the Win32 cmd console?
I found out what the problem was. Although the ftype and the assoc values were set as suggested, the actual behavior on my system seems to be determined by the registry key
HKEY_CLASSES_ROOT\Applications\perl.exe\shell\open\command
It should have a (Default)
string value of "C:\Perl\bin\perl.exe" "%1" %*
When I found this entry, it was set to "C:\Perl\bin\perl.exe" "%1"
. Changing it immediately fixed the problem.
Why it was set that way in the first place? I don't know. Maybe from a previous installation?
Anyway, thanks for the suggestions, and I hope this answer helps someone else, too.
Hmmm... sounds like the file association for *.pl is messed up somehow. I'm not on a Windows box, so I can't test this. You can check the file association stuff with either the ASSOC
or FTYPE
command on the command-line. IIRC, "ASSOC .pl
" should tell you what the file type is and "FTYPE
filetype command" tells the shell what to do with a Perl script. Try something like:
C:\> ASSOC .pl=perlscript
C:\> FTYPE perlscript=C:\Perl\bin\perl.exe %1 %*
From the looks of one of the command references that should do the trick. My guess is that the current association is not passing the parameters along to the script. You should be able to check that by using ASSOC .pl
to figure out what the name of the file association is and then using FTYPE
to print out the command that the shell is going to execute.
Update
I found an interesting thing that I want to note for posterity. I started seeing exactly this problem on a friends machine at work with respect to some Python scripts. ASSOC
and FTYPE
resulted in the expected output but the parameters were still not being passed along - exactly what was originally reported.
After a little digging, I found that the registry settings were created somewhere along the line as REG_SZ
values. I deleted them and re-created them using ASSOC
and FTYPE
and everything started working... looking at the registry gave me the answer the new values were created as REG_EXPAND_SZ
! These worked exactly as expected.