Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to utilize powershell to open an application with a command?

Tags:

powershell

Is there a command that exists that will open any application from PowerShell?

When typing in "notepad", this will open Microsoft Notepad. However, other applications do not seem to open this way.

like image 356
JDavila Avatar asked Nov 08 '16 17:11

JDavila


People also ask

Can I use PowerShell to open a program?

The next method to run .exe files in PowerShell is by using the Start-Process cmdlet. This cmdlet starts one or more processes on your local device. This will run the executable file.

How do I Run a PowerShell program from the command line?

Running a PowerShell script from the Command Prompt If you would like to run a PowerShell script in CMD, you'll need to execute it by calling the PowerShell process with the -File parameter, as shown below: PowerShell -File C:\TEMP\MyNotepadScript. ps1. PowerShell -File C:\TEMP\MyNotepadScript.


1 Answers

Notepad runs in this way not because of any Powershell magic, but because notepad.exe exists in one of the directories specified in your $env:PATH environment variable. The system behaves the same as when using cmd.exe (Command Prompt) in this regard.

You can start any application by specifying the full path to its executable: C:\Program Files\FileZilla FTP Client\filezilla.exe. You can optionally use Start-Process with the EXE if you want to capture a reference to the executable to gain more control over it from Powershell.

like image 108
alroc Avatar answered Nov 15 '22 09:11

alroc