Even though you can run such files by double-clicking them using File Explorer, the method may not be ideal for every situation. You can also run executable (.exe) files directly from Windows PowerShell. Some people may prefer the command-line method as you can run an executable without having to navigate here and there. In this article, we show you 4 methods to run .exe files directly inside PowerShell. The commands discussed in the methods below can also be applied to PowerShell scripts. Moreover, some of them even allow you to send parameters/values to the executable file.
How to Run EXE Files in PowerShell
In all of the methods discussed below, you must know the complete directory path to the file that you want to run in PowerShell. While one of the methods requires you to navigate to the .exe file directory and then execute the file, the other methods need complete file paths in the command.
How to Run EXE Files in PowerShell Run EXE File Directly from PowerShell Run EXE File in PowerShell Using Invoke-Expression Command Run EXE File in PowerShell Using Start-Process Command Run EXE File in PowerShell Using “&” Call Operator Closing Thoughts
In the example below, we will be running “Rufus.exe” located at “C:\Users\Subhan\Downloads.” Of course, this will change for you according to the file’s path and its name.
Run EXE File Directly from PowerShell
When we say “directly,” we mean that this method to run an executable file does not need any special PowerShell commands. All it needs is a path and the name of the file to run. Note that it is crucial that you use “.\” while running an executable file directly. Otherwise, it will be considered a PowerShell command and you may see an error. Alternatively, you can also jump one folder at a time using the following pattern: Note: Apart from the [FileName], you can also change the file type/extension depending on the actual file type. The executable file will now run. You can also run the executable file whilst sending a parameter to the file, as in the example below: In this example, the parameter “10” will be sent to Rufus.exe. Additionally, if you find yourself lost while navigating/changing the directories, or are unsure of the file name, you can use the following cmdlet to get a list of the items inside the current directory:
Run EXE File in PowerShell Using Invoke-Expression Command
Another way to run an executable file using PowerShell is by using the “Invoke-Expression” cmdlet. You can use this cmdlet directly in PowerShell, or insert the full command inside a PowerShell script (.ps1) to run an executable. This way, you can open a document file directly inside the app/program you are writing the script for. To run an executable file in PowerShell or PowerShell script, use the following command syntax: Alternatively, the following syntax also works just as well:
Run EXE File in PowerShell Using Start-Process Command
Like the Invoke-Expression cmdlet, you can also use the “Start-Process” command to run an executable file or a PowerShell script. Here’s how: Alternatively, you can also change your strategy to a directory-first approach and use a different syntax of the “Start-Process” command to run an executable file. For that, you must first use the “CD” cmdlet to change your directory to the location where the executable file is located, then use the following command to run it: That’s it! The executable file should now run. Here is an example:
Run EXE File in PowerShell Using “&” Call Operator
A Call Operator in Windows PowerShell allows you to run a command, function, or script. Anything followed by the “&” call operator is considered a command by PowerShell. You can use this logic of PowerShell to run an executable file simply by entering the file’s path prefixed with the call operator. This is the syntax to be used to run an executable file in PowerShell: It is that simple.
Closing Thoughts
The easiest way to run an executable file, may it be a .exe, .ps1, or .msi file, is perhaps using the “&” call operator followed by the complete file path and extension. However, there are other ways to get the job done as well:
Run the executable in PowerShell directly by using “.\” followed by the file name. Run the executable in PowerShell using the Invoke-Expression command. Run the executable in PowerShell using the Start-Process command.
All of the 4 aforementioned methods will execute the file directly from PowerShell. This way, you do not have to browse through File Explorer to run a file each time you need to.