Helping millions of people navigate the world of technology.

5 Ways to Run Executables (EXE) From PowerShell

Windows executables (EXE files) are the backbone of many applications. Whether installing software, running a system tool, or automating tasks, understanding how to launch EXEs is essential. While you can run these files from the graphical interface, PowerShell is another versatile tool loved by many. In this article, we’ll guide you in running executables (EXE) from PowerShell.

How to Run Executables EXE From PowerShell

Running EXE files from PowerShell allows you to automate repetitive processes, execute commands with specific parameters, and integrate executable tasks seamlessly into scripts. This method makes it easy to take advantage of everything PowerShell can do. You can manage your Windows system more smoothly and get more done.

Method 1: Run EXE File Using .\ (Dot Slash)

To run an executable file (EXE) located in your PowerShell working directory, use the .\ (dot slash) prefix. This tells PowerShell to execute the file from the present folder rather than searching for it within the directories in your system’s PATH environment variable.

Step 1: Press Windows + S on your keyboard, type PowerShell, and click Run as Administrator. Select Yes when prompted.

Press Windows S type PowerShell and click Run as Administrator

Step 2: Navigate to the EXE location. Use the cd command to go to the folder containing your EXE file. For instance:

cd C:\Programs\MyProgramFolder
Navigate to the EXE location

Step 3: Now, run the EXE. Type .\ followed by the name of the EXE file and press Enter. Example:

.\myprogram.exe
Run the EXE

Step 4: If facing problems locating EXE files, use the Get-ChildItem command. Here’s how to use it:

Get-ChildItem *.exe
Locate EXE files using Get ChildItem command

Also Read: How to fix unable to run EXE files on Windows 11

Method 2: Launch an EXE File With the Help of Call Operator (&)

The call operator (&) offers a straightforward way to execute EXE files directly from the PowerShell prompt. Using this method is ideal when you’re looking for quick and simple execution and don’t need complex control over the launch process.

Step 1: Launch the Run box by pressing Windows + R on your keyboard. Type PowerShell in the search box and click OK.

Now, a PowerShell window will open, but note that it’s not in Administrator mode.

Press Windows R type PowerShell and click OK

Step 2: To run PowerShell as an administrator, type the command below and hit Enter. Additionally, click Yes when prompted.

Start-Process powershell -Verb runAs
Run PowerShell as an administrator

Step 4: Now, a new Administrator PowerShell window will open with a blue background as the base.

Step 5: In the new Administrator PowerShell window, type & operator followed by the full path to the EXE file and hit Enter.

& 'C:\Program Files\MyProgram\MyProgram.exe'
Use operator to launch EXE file

Step 6: If your EXE file requires command-line arguments, add them after the file path. Here’s how to do so:

& 'C:\Program Files\ExampleSoftware\program.exe' arg1 arg2 arg3

Note: The argument /p in the image below will print the EXE file whose path has been specified later.

Use augments with the operator

Also Read: How to run PowerShell as administrator in Windows 11

Method 3: Run EXE via the Invoke-Expression Cmdlet

The Invoke-Expression cmdlet in PowerShell offers a way to execute strings as if they were direct commands dynamically. This enables you to run EXE files by providing the full path to the executable. This method can save your life when you need to build the command string for the executable at runtime.

Step 1: Click the Windows icon, type PowerShell in the search box, and select Run as Administrator. When a pop-up appears, choose Yes.

Launch PowerShell

Step 2: Write the command below to run an EXE file and hit Enter on your keyboard.

Invoke-Expression -Command "C:\path to\filename.exe"
Run an EXE file using Invoke Expression

Step 3: If you want to add arguments while launching the EXE file, enter the below arguments and press Enter.

Invoke-Expression "C:\path\to\your\file.exe arg1 arg2 arg3"
Use arguments with Invoke Expression

If you’re dealing with a complicated script involving different paths and arguments, create a variable for these paths and arguments. Later, you can use this variable to simplify the process. Follow the steps below to do so:

Step 1: Set the exe path by typing the below commands and hitting Enter.

$exePath = "C:\myapp.exe"
Set the exe path

Step 2: If you want to run an executable (EXE) with arguments, write the commands below and press Enter.

$arguments = "-arg1 -arg2"
Set arguments

Step 3: Lastly, write the code below to run an executable file and hit Enter.

Invoke-Expression "$exePath $arguments"
Run the executable file with Invoke Expression

Method 4: Launch an EXE File Using CMD /C

The ‘CMD /C’ command in PowerShell essentially creates a temporary instance of the classic Command Prompt (cmd.exe) to execute a specified command. Here’s how to do so:

Step 1: Click the Start button, write PowerShell, and click Run as Administrator. Select Yes to allow the app to make changes to your device.

Launch PowerShell

Step 2: Type the command below to make a cmd instance in your PowerShell window and hit Enter.

cmd /c "path_to_your_exe_file"
Launch an EXE file with the help of cmd

Step 3: If you’re looking to run arguments, type the code below and press the Enter key.

cmd /c "path_to_your_exe argument1 argument2"
Run arguments while using cmd c to launch an EXE file

Also Read: Difference between Command Prompt and PowerShell

Method 5: Using Start-Process Cmdlet

The Start-Process cmdlet offers significant control over the execution process. You should use it to specify command-line arguments, adjust the working directory, redirect output, or launch a process with elevated permissions (administrator rights) using certain parameters.

Step 1: Press Windows + S on your keyboard, write PowerShell, and click Run as Administrator. Select Yes in the pop-up window.

Press Windows S type PowerShell and click Run as Administrator

Step 2: Write the command below and hit Enter to open an EXE app using Start-Process.

Start-Process name.exe
Open an EXE app using Start Process

Step 3: If you want to open a specific EXE file, type the following command and press Enter on your keyboard.

Start-Process -FilePath "filepath.exe"
Open an EXE file using Start Process

Step 4: You can also run arguments while passing the parameters. Write the below command to do so and hit Enter.

Start-Process -FilePath "filename.exe" -argumentList "path_of_the_exe_file"
Use arguments while opening an EXE file in Start Process

Also Read: How to update PowerShell in Windows

Common Parameters

Here are some of the most useful parameters for customizing how Start-Process works:

  • -FilePath: Specifies the path to the executable, script, or document.
  • -ArgumentList: Provides a list of arguments to pass to the process.
  • -WorkingDirectory: Sets the initial working directory for the process.
  • -Verb: Specifies the action to perform on the file (like “open”, “edit”, “print”). Use Get-Verb to see available verbs.
  • -WindowStyle: Determines the window’s initial style (Normal, Hidden, Minimized, Maximized).
  • -Wait: Causes PowerShell to wait for the process to exit before continuing.
  • -PassThru: Returns a process object, providing details and control over the started process.

FAQs

1. Are there any security risks involved in running EXEs from PowerShell?

Yes, running EXEs from PowerShell carries significant security risks. The EXE could be malicious, grant attackers unauthorized access, run harmful code, or steal data.

2. How can I handle errors if the EXE execution fails?

Use PowerShell’s try…catch blocks to capture potential errors during EXE execution, allowing you to log the failure or take corrective actions.

Execute EXE With Parameters

We hope the above methods help you run executables (EXE) from PowerShell. You may significantly improve your ability to automate and manage Windows-based processes by using PowerShell. Which would you rather use, a graphical user interface or a command-line interface like PowerShell? Tell us in the comments below.

Was this helpful?

Thanks for your feedback!

Last updated on 22 February, 2024

The article above may contain affiliate links which help support Guiding Tech. The content remains unbiased and authentic and will never affect our editorial integrity.