4 Ways To Run Executable (.EXE) Files Using PowerShell

3 Ways To Run EXE Files Using PowerShell3 Ways To Run EXE Files Using PowerShell

.EXE files, or “executable files” are something we see often. Most downloaded files, especially setups, are executable files that are ready to be run and installed on your system. At other times, files may still be executable but have a different file extension, like “.msi”, “.bat”, or “.inf”.

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.

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.

  1. Launch an elevated PowerShell instance.

  2. Use the “CD” command to change the directory to the executable file’s location:

    CD "[PathToExecutableFile]"
    Change directory using CD command
    Change directory using CD command

    Alternatively, you can also jump one folder at a time using the following pattern:

    # Change directory to the root of the current volume
    CD\
    # Change direcoty to root of the C drive
    CD C:
    CD Users
    CD Subhan
    CD Downloads
  3. Now that you’re inside the directory of the file, use “.\” followed by the complete name of the executable file.

    Note: Apart from the [FileName], you can also change the file type/extension depending on the actual file type.

    .\[FileName].exe
    Run the executable file from PowerShell directly
    Run the executable file from PowerShell directly

    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:

    .\Rufus.exe 10

    In this example, the parameter “10” will be sent to Rufus.exe.

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.

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:

Get-ChildItem
get list of elements inside directory in PowerShell using Get ChildItem
Get list of elements inside directory in PowerShell using Get-ChildItem

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:

Invoke-Expression -Command “[PathToExecutableFile].exe”

Alternatively, the following syntax also works just as well:

“[PathToExecutableFile].exe” | Invoke-Expression
Run executable file from PowerShell using Invoke Expression command
Run executable file from PowerShell using Invoke-Expression command

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:

  1. Launch an elevated PowerShell instance.

  2. Use the following cmdlet to run an executable file:

    Start-Process -FilePath ‘[PathToExecutableFile].exe’
    Run executable file from PowerShell using Start Process command
    Run executable file from PowerShell using Start-Process command

    That’s it! The executable file should now run.

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:

Start-Process [ExecutableFileName].exe

Here is an example:

Run executable file from PowerShell using Start Process command2
Run executable file from PowerShell using Start-Process command

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:

& "[PathToExecutableFile].exe"
Run executable file from PowerShell using call operator
Run executable file from PowerShell using the “&” call operator

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.

If you liked this post, Share it on:
Subhan Zafar is an established IT professional with interests in Windows and Server infrastructure testing and research, and is currently working with Itechtics as a research consultant. He has studied Electrical Engineering and is also certified by Huawei (HCNA & HCNP Routing and Switching).

Get Updates in Your Inbox

Sign up for the regular updates and be the first to know about the latest tech information