Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

powershell

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". 
like image 638
Neil Justice Avatar asked Mar 20 '12 18:03

Neil Justice


People also ask

How do I remove restrictions in PowerShell?

Procedure. Select Start > All Programs > Windows PowerShell version > Windows PowerShell. Type Set-ExecutionPolicy RemoteSigned to set the policy to RemoteSigned. Type Set-ExecutionPolicy Unrestricted to set the policy to Unrestricted.

How do I stop a PowerShell script execution?

Open a PowerShell console session, type exit , and press the Enter key. The PowerShell console will immediately close. This keyword can also exit a script rather than the console session.

Can all PowerShell scripts can run by default in Windows 10?

The default execution policy for Windows 10. You can't run any PowerShell scripts and PowerShell is set to interactive mode so that you can only run individual commands. Default for server installs. You can run downloaded PowerShell scripts, but they must be signed by a trusted publisher.

Do Windows PowerShell scripts work by default?

PowerShell does not allow external script execution by default. The ExecutionPolicy setting in PowerShell prevents execution of external scripts by default in all versions of Windows. In some Windows versions, the default doesn't allow script execution at all.


1 Answers

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+";." 
like image 192
manojlds Avatar answered Nov 11 '22 21:11

manojlds