Windows 10上的Perl脚本从Explorer而不是命令提示符运行 [英] Perl Scripts on Windows 10 run from Explorer but not Command Prompt

查看:1253
本文介绍了Windows 10上的Perl脚本从Explorer而不是命令提示符运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的新Windows 10电脑上安装了ActiveState Perl。我已经在我自己的几台PC上安装了相同版本的Perl,它安装在我公司其他用户的PC上。

I've installed ActiveState Perl on my new Windows 10 PC. I've installed the same exact version of Perl on several of my own PC's, and it's installed on 100's of other users' PC's in my company. Same exact install, created by me.

这是第一次在Windows 10上进行此操作。双击Perl脚本(* .pl)的基本操作Explorer会导致打开控制台窗口并运行Perl来运行脚本。

This is the first time trying this on Windows 10. The basic actions of double-clicking a Perl script (*.pl) in Explorer cause a console window to open and Perl to run the script.

此外,在Windows命令提示符中,我可以键入 perl.exe脚本。 pl ,脚本运行正常。但是,当我输入 script.pl 时,没有任何反应。没有输出,没有错误,没有perl.exe进程在任务管理器中可见。

Also, in Windows Command Prompt, I can type perl.exe script.pl, and the script runs fine. But, when I just type script.pl, nothing happens. No output, no errors, no perl.exe processes visible in Task Manager.

我第一次运行Perl脚本(从Windows命令提示符, script.pl 语法),Windows弹出一个窗口,询问我要用什么程序打开此文件。 Perl是默认值,我点击确定。

The first time I ran a Perl script (from Windows Command Prompt, I believe, using just the script.pl syntax), Windows popped up a window asking me what program I wanted to use to open this file. Perl was the default, and I clicked OK.

我从来没有在Windows 7或8中看到这个窗口,所以我认为这是Windows 10,并且这是不知何故阻止我只是键入 script.pl 。因为,当启动 script.pl 时,我要求文件关联选择正确的程序,但是当我键入 perl.exe script.pl ,perl.exe正在直接启动。但是,Windows 10选择您的默认程序的事情是通过打乱文件关联从命令提示符下运行的方式。

I've never seen that window in Windows 7 or 8, so I'm thinking it's something specific to Windows 10, and that it's the thing that's somehow preventing me from just typing script.pl. Because, when launching script.pl, I'm requiring the file associations to pick the right program, but when I type perl.exe script.pl, perl.exe is being launched directly. But, that Windows 10 "pick your default program" thing is getting in the way when running from the command prompt by messing up the file associations.

不是100%确定为什么它从Explorer工作,但我很确定,我需要清除默认程序的事情。我删除了 .pl 下的注册表项 HKEY_CURRENT_USER \Software \Microsoft\Windows \CurrentVersion\Explorer\FileExts ,但这没有帮助。

Not 100% sure why it works from Explorer, though, but I'm pretty sure that I need to clear that default program thing. I removed the registry entry for .pl files under HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts, but that didn't help.

这似乎是一个更普遍的问题,Windows 10,或者可能只是我的安装,组策略我不知道。

This seems to be a more generic problem with Windows 10, or possibly just my installation of it, or a Group Policy I'm not aware of.

以下命令(在管理命令提示符下运行)在Windows 8.1而不是Windows 10中正常工作:

The following commands (run in a Admin command prompt) work fine in Windows 8.1 but not Windows 10:

assoc .foo=Foobar
ftype Foobar=C:\WINDOWS\system32\foo.bat %1
echo @echo off > foo.bat
echo echo The filename is %1 >> foo.bat
echo hi > foo.foo
foo.foo

结果应该是输出:

The filename is C:\WINDOWS\system32\foo.foo

但是Windows 10什么都不做。它似乎只允许以这种方式关联内置应用程序,而不是下载/安装EXE的BAT脚本。

But Windows 10 does nothing. It seems to only allow built-in apps to be associated in this manner, and not BAT scripts of downloaded/installed EXEs.

推荐答案

结果,微软扭转了Windows 10中的注册表设置的极性,这也是其他Perl程序员。解决方案是将HKEY_LOCAL_MACHINE \Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\InheritConsoleHandles设置为0。

Turns out that Microsoft reversed the polarity of a Registry setting in Windows 10, and this is biting other Perl programmers too. The solutions is to set HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\InheritConsoleHandles to "0".

MSDN在这里: https://social.msdn.microsoft.com/Forums/en-US/f19d740d-21c8-4dc2-a9ab-d5c0527e932b/nasty-file-association-regression-bug-in-windows- 10控制台

这篇关于Windows 10上的Perl脚本从Explorer而不是命令提示符运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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