How To Run Exe In Powershell

3 min read

How to Run EXE in PowerShell: The Complete Practical Guide

Running an .exe file in PowerShell looks deceptively simple until you hit a path with spaces, an application that needs arguments, or a process whose exit code you actually need to read. This guide covers how to run EXE in PowerShell from the basic invocation all the way to advanced process control, including Start-Process, working directories, argument quoting, output redirection, and troubleshooting the errors that trip up most beginners Easy to understand, harder to ignore..

Real talk — this step gets skipped all the time.

The Shortest Possible Answer

In PowerShell, an executable is not a special kind of object — it is a command. If PowerShell can resolve it, typing the name runs it:

notepad.exe
ipconfig /all

PowerShell searches for the executable in this order: aliases and functions, cmdlets, then external programs found in the directories listed in the $env:PATH environment variable. This is why notepad.Also, exe works from any folder while C:\Tools\myapp. exe only works when you give the full path It's one of those things that adds up..

Method 1: Direct Invocation with the Call Operator

The single most useful operator for this task is &, the call operator. It tells PowerShell "treat what follows as a command to execute," which matters in two situations No workaround needed..

When the path is a quoted string. PowerShell normally interprets a bare string as text to output, not a command to run:

# This prints the string instead of launching the app
"C:\Program Files\MyApp\app.exe"

# This actually launches it
& "C:\Program Files\MyApp\app.exe"

When the path lives in a variable. This is the pattern you will use in scripts:

$exe = "C:\Tools\7zip\7z.exe"
& $exe l "C:\Backups\archive.7z"

If the variable holds a command name plus arguments in one string, use splatting or an array instead of & for reliability Most people skip this — try not to..

Method 2: Start-Process for Real Control

The & operator runs the executable synchronously — PowerShell waits. Start-Process is the dedicated cmdlet for launching programs when you need control over the how:

Start-Process -FilePath "notepad.exe"

Its most valuable parameters:

  • -ArgumentList — passes arguments to the program.
  • -WorkingDirectory — sets the child process's current folder, which many legacy applications depend on for finding config files.
  • -Wait — blocks the script until the process exits.
  • -NoNewWindow — keeps console output in the current terminal instead of opening a new window.
  • -PassThru — returns a System.Diagnostics.Process object you can inspect.
  • -Verb RunAs — triggers a UAC prompt and launches elevated.
  • -Credential — runs the process as a different user.
  • -WindowStyle — Normal, Hidden, Minimized, or Maximized.

A realistic combined example:

$proc = Start-Process -FilePath "setup.exe" `
    -ArgumentList "/quiet", "/norestart" `
    -WorkingDirectory "C:\Installers" `
    -Wait -PassThru -NoNewWindow

"Installer exited with code $($proc.ExitCode)"

Choosing Between & and Start-Process

Need Use
Launch quickly and wait &
Pass a path in a variable & with call operator
Control working directory Start-Process
Launch elevated Start-Process -Verb RunAs
Capture exit code object Start-Process -PassThru -Wait
Redirect stdout/stderr to files Start-Process
Run hidden or minimized Start-Process -WindowStyle

Passing Arguments Correctly

Argument handling is where most "my script works manually but fails automatically" bugs live. PowerShell 7.3+ changed native argument passing behavior, controllable through $PSNativeCommandArgumentPassing.

  1. Use an array for arguments so each element stays distinct:
    $args2 = @("/log", "C:\Logs\install.txt", "/silent")
    Start-Process -FilePath "installer.exe" -ArgumentList $args2 -Wait
    
  2. Quote values that contain spaces, and embed the quotes inside the string:
    & "C:\app\app.exe" -Name "John Doe" -Path "C:\My Files"
    
  3. Use the stop-parsing symbol --% when you need the rest of the line handed to the program exactly as typed, bypassing PowerShell parsing:
    & "C:\app\app.exe" --% /output="C:\a b\c"
    

Reading Exit Codes and Errors

This is the step beginners skip, and it

Still Here?

Just Went Online

You'll Probably Like These

You Might Want to Read

Thank you for reading about How To Run Exe In Powershell. We hope the information has been useful. Feel free to contact us if you have any questions. See you next time — don't forget to bookmark!
⌂ Back to Home