如何在 Vista 64 中通过文件关联传递命令行参数? [英] How can I pass command-line arguments via file association in Vista 64?

查看:29
本文介绍了如何在 Vista 64 中通过文件关联传递命令行参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 Vista 64 中通过文件关联传递命令行参数?

How can one pass command line arguments via file association in Vista 64?

我最近构建了一台运行 Vista Ultimate 64 位的 PC.我注意到我传输的几个 Perl 脚本由于没有传递命令行参数而失败.作为一个简单的测试,我写了以下(foo.pl):

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
";
print "$^X
" # to see what was being used

运行foo.pl 1 2 3"的结果不理想:

Running "foo.pl 1 2 3" undesirably yielded:

0 arguments read
C:strawberryperlinperl.exe

按预期运行perl foo.pl 1 2 3":

Running "perl foo.pl 1 2 3" expectedly yielded:

3 arguments read
C:strawberryperlinperl.exe

在我的旧 Windows XP PC 上,两次调用都返回了 3 个参数.我在这里记录了更多我的调查(win32.perl.org wiki谈话),但我还没有找到有效的解决方案.

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.

我也试过 ActivePerl-5.10.0.1004-MSWin32-x64-287188.msi 无济于事.

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.

推荐答案

我刚刚在我的 Vista 64 Ultimate 上尝试了 ActivePerl-5.10.0.1004-MSWin32-x64-287188.msi 并且它有效.

I just tried ActivePerl-5.10.0.1004-MSWin32-x64-287188.msi on my Vista 64 Ultimate and it worked.

F:progperl>foo.pl 1 2 3
3 arguments read
C:Perl64inperl.exe

这意味着 devio 是对的:一定是文件关联"问题;

That means devio is right: it must be an "file association" issue;

在资源管理器上,右键单击您的 .pl 文件并询问打开方式":使用Perl 命令行解释器",它将起作用(并选择始终使用此程序打开此类文件").

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").

对我来说,Vista 的文件扩展管理器删除了将参数传递给函数的能力"似乎是错误的......

To me, "Vista's file extension manager removed the ability to pass arguments to functions" seems wrong...

我确实看到了:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOTPerlshellOpencommand]
@=""C:\Perl64\bin\perl.exe" "%1" %*"

意思是如果您的安装没有在您的注册表中放置那种值,那是因为:

Meaning if your installation did not put that kind of value in your registry, it is because:

  • 您在设置 ActivePerl-5.10.0.1004-MSWin32-x64-287188.msi 时没有选择关联
  • 或者您的帐户没有足够的权限在注册表中写入任何内容.

注意:

  • 似乎 Vista 上的常规扩展管理器不传递参数(意思是 "C:\Perl64\bin\perl.exe" "%1" 没有 <代码>%* 参数)
  • 注册表添加是必要的如 SO 所述
  • it seems the regular extension manager on Vista does not pass argument (meaning "C:\Perl64\bin\perl.exe" "%1" without the %* argument)
  • the registry addition is necessary as documented by the SO

这篇关于如何在 Vista 64 中通过文件关联传递命令行参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆