I've got a Strawberry Perl program that accepts a single-file as a command-line argument. How can I set things up such that I can drag and drop the desired file onto the Strawberry Perl program (or a wrapper around it) and the program runs with that file's name as an argument?
相关问题
- Inheritance impossible in Windows Runtime Componen
- $ENV{$variable} in perl
- how to get running process information in java?
- Is TWebBrowser dependant on IE version?
- How can I have a python script safely exit itself?
相关文章
- 如何让cmd.exe 执行 UNICODE 文本格式的批处理?
- 怎么把Windows开机按钮通过修改注册表指向我自己的程序
- Warning : HTML 1300 Navigation occured?
- Bundling the Windows Mono runtime with an applicat
- Windows 8.1 How to fix this obsolete code?
- Running a perl script on windows without extension
- Comparing speed of non-matching regexp
- CosmosDB emulator can't start since port is al
Here's another alternative to a "wrapper", but it requires a slight modification to the perl script:
The script is run like any other batch file. The first three lines basically invokes Perl on the CMD file itself (
%~f0
, which only works if CMD extensions are turned on). The-x
paremeter to perl.exe tells Perl to skip everything until the#!perl
line. "#line 6
" just aids in debugging.This is my preferred solution when I don't know much about the target system (and may not be able to edit the registry).
Eeek! Please don't create a wrapper script/cmd when you don't need to.
Go into your Registry or your File Type dialog box in Windows, and redefine the Perl default action to say:
This will cause double-clicking the .PL to launch perl.exe with the name of the double-clicked file (%1). The %* stuff (passing any filename arguments to the Perl script) is trickier.
Go into the Registry again (really, it's not as scary as people think) and find/create a "shellex" key under the Perl class, and then create a sub-key called "DropHandler" with a default string value of "{86C86720-42A0-1069-A2E8-08002B30309D}" (at least, that's my DropHandler in the US version of Windows XP).
This allows .pl files (actually, anything associated with the Perl class) to have a drop handler that tells Explorer what to do when you drop file(s) on the .pl script. In this case, it just means "run the Perl script with the dropped file(s) as arguments".
Hmmm, I don't think I explained that very well, but that's how I've set up Perl (running off a network drive) for a large engineering organization. Google for Perl and DropHandler, and you should be able to get the .reg Registry script to do this for you.
Under Windows (tested with XP), you can create a .cmd file and simply have it run the Perl program with the argument of %1 to pass the filename over, as if executed by commandline.
Then you can simply drag and drop a file onto the .cmd file to execute.