How do you remove the PowerShell requirement that

2020-05-25 07:57发布

问题:

How do you remove the PowerShell requirement that scripts and executables be preceded by ".\"?

The PowerShell warning message that is shown when "a.exe" is entered instead of ".\a.exe":

The command a.exe was not found, but does exist in the current location. Windows PowerShell doesn't load commands from the current location by default. If you trust this command, instead type ".\a.exe".

回答1:

It is a security feature so that you do run scripts that you think you are running. That is why unlike cmd, you do not have . ( current directory) in PATH and you have to do .\my.exe etc.

If you don't want to do this and subvert this precaution, add . to your PATH:

$env:PATH =$env:PATH+";."


回答2:

add in your path (evironment variable) the path where you usually put your script and exe file.



回答3:

Rename your script file so that it starts with a '.'.

See https://github.com/PowerShell/PowerShell/issues/9468



回答4:

run the command like so:

C:\flutter\bin> .\flutter doctor


标签: powershell