Windows 上的 Wget 路径环境变量

Wget Path Environment Variable on Windows

在 Windows 10,我安装了 Wget by choco install wget

然后我将 wget.exe 位置文件夹添加到路径环境变量(在安装时是 C:\ProgramData\chocolatey\lib\Wget\tools)。

但是,使用 PowerShell / cmd 的 Wget 命令,例如 wget --helpwget [any_link] 不会立即起作用,它们只有在我输入 wget.exe --helpwget.exe [any_link] 时才会起作用

wget --help 错误:

wget : The remote name could not be resolved: '--help'
At line:1 char:1
+ wget --help
+ ~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

如何禁用显式 .exe 扩展?我知道这是一个小问题,但是当你不经常使用 Wget 时,每次你都需要一些时间来回忆这个烦人的细节...

这是因为 Powershell 已经定义了自己的 wget 命令,它实际上是 Invoke-WebRequest cmdlet 的别名。如果删除别名,则可以使用不带文件扩展名的 wget.exe 命令。试试

Remove-Item Alias:wget
wget --help