How do I make Perl scripts recognize parameters in the Win32 cmd console?

后端 未结 9 1228
时光说笑
时光说笑 2020-12-03 12:46

When I invoke my Perl scripts in the Windows environment without invoking perl first, the parameters are not passed to my script.

For example,



        
9条回答
  •  南方客
    南方客 (楼主)
    2020-12-03 13:17

    To sum up.

    ftype is old and cmd.exe doesn't care whatever it says.

    The real deal is the HKEY_CLASSES_ROOT\Applications\perl.exe\shell\open\command thing.

    Just run: reg add HKEY_CLASSES_ROOT\Applications\perl.exe\shell\open\command /ve /d "C:\strawberry\perl\bin\perl.exe \"%1\" %*" /f

    and everything will be ok. (* given that "C:\strawberry\perl\bin\perl.exe" is the exact path to your perl installation.*)

    /ve is meant to work on de “(Default)” REG_SZ value /d is to assign “data” to the “value” /f to force substitution (or overwriting) of the preexisting value

    In fact, if assoc .pl=Whatever and ftype Whatever doesn't exist (never assigning a value to it, or doing ftype Whatever= to unassign), the scripts could still be invoked without prepending perl.exe.

    So, if using Windows >= 6.0 (Vista, 2008, 7, etc.) just forget that the commands assoc and ftype exist at all. Don't bother. Go reg.exe!

提交回复
热议问题