5 Ways to Run Executables (EXE) Files From PowerShell

Meet Bhaskar, your friendly neighborhood tech enthusiast-turned-wordsmith. For the past few years, he’s been your go-to guide for demystifying iOS, Android, macOS, and Windows platforms. While he holds a B.Tech degree, he has dedicated himself to simplifying tech complexities for all and has lent his expertise to publications like iGeeksBlog, The Writing Paradigm, and more. His forte lies in crafting easy-to-follow how-to guides and in-depth articles, making the intricate world of technology accessible to all. When not immersed in the tech world, you’ll find him enjoying music or sports.

Afam has been a content writer with Guiding Tech Media since August 2023. However, his experience in tech writing dates back to 2018, when he worked as a freelance writer for Make Tech Easier. Over the years, he has grown a reputation for publishing quality guides, reviews, tips, and explainer articles. His work is featured on top websites, including Technical Ustad, Windows Report, and Next of Windows. He has training as a Microsoft Certified Professional and has covered more Microsoft-related guides on these platforms.

Method 1: 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:PressWindows+Son your keyboard, typePowerShell, and clickRun as Administrator. SelectYeswhen prompted.

Step 2:Navigate to theEXElocation. Use thecdcommand to go to the folder containing your EXE file. For instance:

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

Step 4:If facing problems locating EXE files, use theGet-ChildItemcommand. Here’s how to use it:

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

Method 2: Using Call Operator (&)

The call operator (&) offers a straightforward way to execute EXE files directly from the PowerShell prompt. This method is ideal for quick and simple execution and doesn’t require complex control over the launch process.

Step 1:Launch the Run box by pressingWindows+Ron your keyboard. TypePowerShellin the search box and clickOK.

Step 2:To run PowerShell as an administrator, type the command below and hitEnter. Additionally, clickYeswhen prompted.

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

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

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

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

Method 3: Via the Invoke-Expression Cmdlet

The Invoke-Expression cmdlet in PowerShell offers a way to execute strings dynamically as if they were direct commands. 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 theWindowsicon, typePowerShellin the search box, and selectRun as Administrator. When a pop-up appears, chooseYes.

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

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

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 hittingEnter.

Step 2:Write the commands below and pressEnterto run an executable (EXE) with arguments.

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

Method 4: Using CMD /C

PowerShell’s CMD /C command 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 theStartbutton, writePowerShell, and click Run as Administrator. SelectYesto allow the app to make changes to your device.

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

Step 3:To run arguments, type the code below and press theEnterkey.

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:PressWindows+Son your keyboard, writePowerShell, and clickRun as Administrator. In the pop-up window, selectYes.

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

Step 3:To open a specific EXE file, type the following command and pressEnteron your keyboard.

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

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

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.

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

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

Was this helpful?

Last updated on 23 August, 2024

Leave a ReplyCancel reply

Your email address will not be published.Required fields are marked*

Name*

Email*

Comment*

Δ

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.

More in Windows

4 Ways to Fix Graphics Device Driver Error Code 22 on Windows

6 Ways to Fix Xbox Games Installation Stuck on Windows

JOIN THE NEWSLETTER

Get Guiding Tech articles delivered to your inbox.

© 2024 Guiding Tech Media. All Rights Reserved.