Running EXE Files in PowerShell: Simple Commands

Download Article
Open and run .exe files with PowerShell for Windows
Download Article

If you need to launch an executable file from PowerShell, you have several options. If you're in the same directory as the EXE file, type .\ before its filename (e.g., .\notepad.exe) and press Enter. You can run the EXE from a different directory using the PowerShell call operator (&), the Start-Process cmdlet, or the Invoke-Expression cmdlet. Each PowerShell run option is easy and can be used at the command line and in your PowerShell scripts.

Things You Should Know

  • Use .\filename.exe to run an EXE from the current directory in PowerShell.
  • To run an EXE from another directory, you can use & "C:\Windows\notepad.exe"
  • To use the Start-Process cmdlet to run the program, type Start-Process -FilePath "filename.exe"
Section 1 of 4:

Using .\ (Dot Slash)

Download Article
  1. How.com.vn English: Step 1 Use cd to enter the directory that contains the EXE file.
    For example, if you want to run notepad.exe from PowerShell, type cd "C:\Windows\" and press Enter.
  2. How.com.vn English: Step 2 Enter the command to run the EXE file.
    To run an EXE file from the current directory in PowerShell, you'll need to preface the filename with .\. For example, to run notepad.exe, type .\notepad.exe and press Enter.
    • Typing the .\ before the filename tells PowerShell you want to run the EXE file from the current directory.
    • If you want to run the EXE file from a different directory, use the call operator (&).
    Advertisement
  3. How.com.vn English: Step 3 Use Get-ChildItem to locate EXE filenames (if needed).
    If you get an error that says, "The term (EXE file name) is not recognized as a name of a cmdlet, function, script file, or executable program," you're either entering the wrong file name or in the wrong directory. Get-ChildItem shows you all files and permissions in the current directory.
    • To show only EXE files, use Get-ChildItem *.exe.[1]
    • You can also use Get-ChildItem to list files in other directories. For example, to show all executable files in C:\Program Files\Ableton\Live 11 Lite\Program, you'd use "C:\Program Files\Ableton\Live 11 Lite\Program\*.exe".
  4. Advertisement
Section 2 of 4:

Using the Call (&) Operator

Download Article
  1. & "C:
    \Windows\notepad.exe". In PowerShell scripting, you can run any command that's stored in a variable by prefacing its path with an ampersand (&).[2] Similarly, you can use the call operator to run an EXE file from the PowerShell prompt.
Section 3 of 4:

Using Start-Process Cmdlet

Download Article
  1. Start-Process -FilePath "filename.exe"
    . This command will run the executable file called filename.exe from the current directory. If you're not already in the same directory as the EXE file, use the full path to the file, e.g., Start-Process -FilePath "C:\path to\filename.exe".
    • If you need to run an EXE with parameters, enter the parameters after the executable's name. For example, to open Notepad with the window maximized, you'd use Start-Process -FilePath "C:\Windows\notepad.exe" -Wait -WindowStyle Maximized.[3]
  2. Advertisement
Section 4 of 4:

Using Invoke-Expression Cmdlet

Download Article
  1. Invoke-Expression -Command "C:
    \path to\filename.exe". Invoke-Expression is typically used in PowerShell scripts to evaluate expressions, run scripts, and run commands in variables. You can also use it to run any EXE file at the prompt.
    • Microsoft cautions against using Invoke-Expression in PowerShell scripts that accept user input unless the script can verify that the command is safe to run.[4]

Expert Q&A

Ask a Question
200 characters left
Include your email address to get a message when this question is answered.
Submit
      Advertisement

      Tips

      Submit a Tip
      All tip submissions are carefully reviewed before being published
      Thanks for submitting a tip for review!

      About This Article

      How.com.vn English: Luigi Oppido
      Written by:
      Computer & Tech Specialist
      This article was written by Luigi Oppido and by How.com.vn staff writer, Nicole Levine, MFA. Luigi Oppido is the Owner and Operator of Pleasure Point Computers in Santa Cruz, California. Luigi has over 25 years of experience in general computer repair, data recovery, virus removal, and upgrades. He is also the host of the Computer Man Show! broadcasted on KSQD covering central California for over two years. This article has been viewed 66,972 times.
      How helpful is this?
      Co-authors: 2
      Updated: September 4, 2023
      Views: 66,972
      Categories: Windows
      Thanks to all authors for creating a page that has been read 66,972 times.

      Is this article up to date?

      ⚠️ Disclaimer:

      Content from Wiki How English language website. Text is available under the Creative Commons Attribution-Share Alike License; additional terms may apply.
      Wiki How does not encourage the violation of any laws, and cannot be responsible for any violations of such laws, should you link to this domain, or use, reproduce, or republish the information contained herein.

      Notices:
      • - A few of these subjects are frequently censored by educational, governmental, corporate, parental and other filtering schemes.
      • - Some articles may contain names, images, artworks or descriptions of events that some cultures restrict access to
      • - Please note: Wiki How does not give you opinion about the law, or advice about medical. If you need specific advice (for example, medical, legal, financial or risk management), please seek a professional who is licensed or knowledgeable in that area.
      • - Readers should not judge the importance of topics based on their coverage on Wiki How, nor think a topic is important just because it is the subject of a Wiki article.

      Advertisement