Tech News Today
  • Hardware
    • Motherboards
    • CPUs
    • Graphic Cards
    • RAM
    • SSDs
    • Computer Cases
    • Monitors
    • Peripherals
    • Power Supply Unit
    • PC Builds
    • Computer Tips
  • Software
  • Operating System
    • Windows
    • Mac
    • Linux
  • Gaming
  • Mobile
  • Console
  • More
    • Internet
    • Networking
    • Security
    • Buyer’s Guide
    • Gadgets
    • Laptops
    • Reviews
    • How To
    • News
Facebook Twitter Instagram
Tech News Today
  • Hardware
    • Motherboards
    • CPUs
    • Graphic Cards
    • RAM
    • SSDs
    • Computer Cases
    • Monitors
    • Peripherals
    • Power Supply Unit
    • PC Builds
    • Computer Tips
  • Software
  • Operating System
    • Windows
    • Mac
    • Linux
  • Gaming
  • Mobile
  • Console
  • More
    • Internet
    • Networking
    • Security
    • Buyer’s Guide
    • Gadgets
    • Laptops
    • Reviews
    • How To
    • News
Tech News Today
Home»Windows»How to Run Exe in Powershell

How to Run Exe in Powershell

Jabin ManandharBy Jabin ManandharDecember 7, 2022
powershell run

Running an executable (.exe) file is simply a matter of opening it in general cases like installing or opening an application. But, if you are a network/system administrator and want to create a script for automating various tasks, you will likely reach a point where you need to run an executable file.

Well, for Windows users, you already have a built-in tool called Windows PowerShell to do just that. Using it, you can run powerful commands and even build applications with efficient scripts.

In this article, we have compiled a  list of various ways you can use the PowerShell tool to run an .exe file.

Table of Contents

  • How to Run Exe in Powershell?
    • Run Directly without Parameters Using the & Operator
    • Using Start-Process
    • Using Invoke-Expression

How to Run Exe in Powershell?

While running the commands in the methods below, replace the items like filename or path appropriately. Also, exclude the angle brackets and include spaces as is while writing the commands.

Run Directly without Parameters Using the & Operator

With PowerShell, you can directly run an executable file with the” &” operator (also known as the call operator). You can browse to the file location or provide the full address path in the command. Then you can execute the command.

For example:

  1. Press Windows + R, type powershell, and press Ctrl + Shift + Enter to launch PowerShell as administrator.
    Run-PowerShell-as-admin
  2. If your file is already in the same directory, type & ‘.\<filename>.exe’ and press Enter. Furthermore, you can use the cd command to change the directory and the Get-ChildItem command to view the list of all the files/directories inside it.
    Run-Exe-File-in-same-directory-PowerShell
  3. Or, if you have the complete file path, type & ‘<filepath>\<filename.exe>’ and press Enter.
    Run-Exe-file-with-full-path-PowerShell
Note: Using quotes is mandatory only if your filename contains a space. If it’s not the case, you can run the above command without quotes.

If you are wondering what’s happening here, well, by typing the ampersand (&) symbol, PowerShell understands that it needs to run the program. Otherwise, PowerShell will treat the command as a string and won’t invoke the .exe file.

Using Start-Process

Start-Process is a more advanced and powerful cmdlet where you can specify multiple parameters. Thus, it can run several executable files at once.

Syntax:

Start-Process -FilePath “<Path>”

Here, we are using the Path parameter to specify the file path of the executable file. Along with the above parameter, some of the commonly used parameters with syntax are listed below.

Start-Process -FilePath "<FilePath\<file-name>.exe" -Wait 

Run-Exe-file-with-Start-Process-Wait-parameter

This command tells PowerShell to wait until the whole process finishes executing and then takes other inputs if any.

Start-Process -FilePath "powershell" -Verb RunAs

Start-Process-command-including-Verb-parameter

The above command launches PowerShell as administrator. Instead of the RunAs verb, you can also use Open and RunAsUser verbs for the .exe files.

Using Invoke-Expression

While this method can run .exe file in PowerShell, Microsoft itself doesn’t recommend using it. This is because many things can go wrong when using it, such as being susceptible to code injection attacks and difficulty maintaining code.

Therefore, only use it if you are sure what’s going to happen, and be careful, especially in cases where a user can enter an unsafe command.

Syntax:
Invoke-Expression -Command “.\filepath\<filename>.exe” 

Already-in-current-directory

In the above image, we are already in the D directory that contains the GoogleDriveSetup.exe file we want to run. So, we write the following command.

Invoke-expression -command ".\ExeFolder\GoogleDriveSetup.exe"

Running-Invoke-Expression-in-Current-Directory

On the other hand, if we were in a different directory and wanted to run the above file, we wouldn’t need to append .\ in front of the file. The .\ represents that we are in the current directory of the desired file. Hence the command becomes:

Invoke-expression -command “D:\a.exe”

Invoke expression full path other directory
how to
Jabin Manandhar

Jabin is an IT Graduate. Working for almost a year as a tech writer, Jabin has covered a gamut of articles, ranging from Windows troubleshooting, Android, iOS to Internet-related issues. Besides them, he is experienced in Microsoft Office programs and has written numerous articles on Outlook, Excel, and Word. Most of his work includes resolving various Outlook issues and general software fixes. You can contact him at jabin@technewstoday.com

Related Posts

antimalware service executable high memory

Fix: Antimalware Service Executable High Memory

May 18, 2023
windows event logs

How to Check Event Logs on Windows

May 17, 2023
the rpc server is unavailable

Fix: The RPC Server is Unavailable

May 15, 2023
DirectStorage Windows 11

How to Enable DirectStorage on Windows 11

May 15, 2023
audio keeps cutting out

5 Ways to Fix Audio Keeps Cutting Out on Windows 11

May 12, 2023
MBR Error 1 2 3

What is MBR Error 1, 2, 3? 7 Ways to Fix It

May 11, 2023
Add A Comment

Leave A Reply Cancel Reply

Latest Posts
Best-1200W-PSU

8 Best 1200W PSUs for Extreme PC Builds in 2023

May 16, 2023
Best-1000W-PSU

10 Best 1000W PSUs in 2023

May 16, 2023
best-700w-psu

10 Best 700W PSUs for Gaming in 2023

May 14, 2023
You may also like
antimalware service executable high memory

Fix: Antimalware Service Executable High Memory

May 18, 2023
printer-printing-pink

Why is My Printer Printing Pink? 6 Ways to Fix It

May 18, 2023
how to clean usb c port

How to Clean USB-C Port Safely

May 17, 2023
Recommended
Cookie Clicker Garden Guide

Cookie Clicker Garden Guide to Unlocking Every Seed

September 26, 2021
monitor no signal

Computer Turns On But Monitor Says No Signal (9 Ways To Fix)

November 10, 2022
Facebook Twitter Pinterest
  • Home
  • About Us
  • Our Team
  • Editorial Guidelines
  • Privacy Policy
  • Affiliate Disclosure
© 2023 TechNewsToday, editor@technewstoday.com | Tech Central Pvt. Ltd.

Type above and press Enter to search. Press Esc to cancel.