如何在 Vista 64 中通过文件关联传递命令行参数?
如何在 Vista 64 中通过文件关联传递命令行参数?
我最近组装了一台运行 Vista Ultimate 64 位的 PC。 我注意到我传输的几个 Perl 脚本由于未传递命令行参数而失败。 作为一个简单的测试,我编写了以下内容 (foo.pl):
#!/usr/bin/perl -w
use strict;
my $num_args = $#ARGV + 1;
print "${num_args} arguments read\n";
print "$^X\n" # to see what was being used
运行“foo.pl 1 2 3”意外产生:
0 arguments read
C:\strawberry\perl\bin\perl.exe
运行“perl foo.pl 1 2 3”预期产生:
3 arguments read
C:\strawberry\perl\bin\perl.exe
在我的旧 Windows XP PC 上,两个调用都返回3 个参数。 我在这里记录了更多我的调查(win32.perl.org wiki talk),但我还没有找到有效的解决方案。
我也尝试过 ActivePerl-5.10.0.1004-MSWin32-x64-287188.msi 无济于事。
任何帮助,将不胜感激。 这让我抓狂。
How can one pass command line arguments via file association in Vista 64?
I recently built a PC running Vista Ultimate 64-bit. I noticed several of the Perl scripts I transferred failed due to command-line arguments not being passed. As a simple test, I wrote the following (foo.pl):
#!/usr/bin/perl -w
use strict;
my $num_args = $#ARGV + 1;
print "${num_args} arguments read\n";
print "$^X\n" # to see what was being used
Running "foo.pl 1 2 3" undesirably yielded:
0 arguments read
C:\strawberry\perl\bin\perl.exe
Running "perl foo.pl 1 2 3" expectedly yielded:
3 arguments read
C:\strawberry\perl\bin\perl.exe
On my old Windows XP PC, both invocations returned 3 arguments. I documented more of my sleuthing here (win32.perl.org wiki talk), but I've yet to find a solution that works.
I've also tried ActivePerl-5.10.0.1004-MSWin32-x64-287188.msi to no avail.
Any help would be appreciated. This is driving me batty.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我刚刚在 Vista 64 Ultimate 上尝试了 ActivePerl-5.10.0.1004-MSWin32-x64-287188.msi,它成功了。
这意味着 devio 是对:肯定是“文件关联”问题;
在资源管理器上,右键单击 .pl 文件并询问“打开方式”:使用“Perl 命令行解释器”,它将起作用(并选择“始终使用此程序打开此类文件”)。
对我来说,“Vista 的文件扩展管理器删除了向函数传递参数的能力”似乎是错误的...
我确实明白:
这意味着如果您的安装没有在注册表中放入这种值,那是因为:
注意:
\"C:\\Perl64\\bin\\perl.exe\" \"%1\"
没有%*
参数)I just tried ActivePerl-5.10.0.1004-MSWin32-x64-287188.msi on my Vista 64 Ultimate and it worked.
That means devio is right: it must be an "file association" issue;
On an explorer, right-click on your .pl file and ask "Open with": use the "Perl Command Line interpreter" and it will work (and select "always use this program to open this type of file").
To me, "Vista's file extension manager removed the ability to pass arguments to functions" seems wrong...
I do see:
Meaning if your installation did not put that kind of value in your registry, it is because:
Note:
\"C:\\Perl64\\bin\\perl.exe\" \"%1\"
without the%*
argument)不知道 Vista 和 64 位,但在“经典”版本的 Windows 下,您可以编辑注册表:
包含默认字符串 “Perl”
包含默认字符串:
其中 %* 是第一个之后的所有参数的宏。 可能 %* 丢失了。
Don't know about Vista and 64bits, but under "classic" versions of Windows you can edit the registry:
contains default string "Perl"
contains the default string:
where %* is a macro for all parameters following the first. Probably the %* is missing.
Vista 的文件扩展管理器删除了向程序传递参数的功能。 您必须像 devio 提到的那样手动编辑注册表(或使用其他程序来编辑文件扩展名)。
Vista's file extension manager removed the ability to pass arguments to programs. You have to manually edit the registry like devio mentions (or use another program to edit file extensions).
对于 Perl 初学者来说,还有趣的是 ARGV 区分大小写 ...只需花一个小时尝试找出为什么我的命令行参数没有传递,而只是我使用了 argv [0] 而不是 ARGV[0] ...
Also interesting to know for a Perl beginner is that ARGV is case-sensitive ... just spend an hour trying to find out why my command line parameters are not passed, and it was just that I used argv[0] instead of ARGV[0] ...