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

jabinBy jabinDecember 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

Hello there! I'm an IT graduate familiar with troubleshooting for Windows, Android, iPhone, and several other devices. I love to help people with thorough how-to guides and interesting tips & tricks. When I'm not writing, I love to watch movies, especially the thriller ones.

Related Posts

start menu wont open

Start Menu Won’t Open? 7 Ways to Fix it

January 13, 2023
motherboard-audio-not-working

Motherboard Audio Not Working? Try These Fixes

January 13, 2023
empty recycle bin for all users

How to Empty Recycle Bin for All Users on Windows

January 10, 2023
how-to-stop-screen-from-turning-off

How to Keep Your Stay Screen On for Longer Time

January 9, 2023
hdmi-laptop-to-displayport-monitor

How to Connect HDMI Laptop to DisplayPort Monitor

January 4, 2023
how to make windows 10 faster

12 Ways How You Can Make Windows 10 Faster

January 4, 2023
Add A Comment

Leave A Reply Cancel Reply

Latest Posts
what is ghost of tsushima legends

What is the Ghost of Tsushima Legends Mode

January 12, 2023
raid 5 vs raid 10

RAID 5 Vs RAID 10 – Which One Is Better?

January 12, 2023
best-tv-settings-for-gaming

Best TV Settings for Gaming

January 9, 2023
You may also like
tv-screen-goes-black-randomly

TV Screen Goes Black Randomly? Try These 11 Fixes

January 15, 2023
how to find unique values in excel

How to Find Unique Values in Excel

January 15, 2023
how-to-open-and-use-chrome-settings

How to Open and Use Chrome Settings

January 16, 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
  • Editorial Guidelines
  • Fact-Checking Policy
  • Privacy Policy
  • Affiliate Disclosure
© 2023 TechNewsToday.

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