Get a free E-Book.

|

Running EXE in PowerShell

PowerShell, a cross-platform automation and configuration tool, is extensively used in the Microsoft environment. With its extensive capabilities, PowerShell can often substitute the Command Prompt entirely. One common use of PowerShell is running executable (EXE) files.

Perhaps you’re working with a newly compiled program or instead automating the launch of a frequently used application. Whatever your challenge, this article aims to deliver a complete guide on running an EXE file in PowerShell.

Table of Contents

Understanding PowerShell

Before diving into the specifics of running EXEs, it’s vital to have a basic understanding of PowerShell. PowerShell is an object-oriented scripting language and interactive command-line interface specially designed for administrators. With PowerShell, you can control and automate the administration of the Windows operating system and applications that run on Windows.

Now, let’s glide into practicalities: running EXE in PowerShell.

Running an EXE File in PowerShell

PowerShell provides several methods to execute an EXE file: Direct Execution (Call Operator), Invoke-Expression cmdlet, and Start-Process cmdlet.

Direct Execution (Call Operator)

In this simplest method, you can run the EXE by directly calling the path of the executable file in the command line. This method, also known as the call operator method, can be used for EXE files on your local machine. Given below is the command syntax.

				
					& "Path_to_exe\yourfile.exe"
				
			

For example, if you have a file named ‘myfile.exe’ on your C:\ drive, you can run it as follows:

				
					& "C:\myfile.exe"
				
			

The Invoke-Expression cmdlet

The Invoke-Expression cmdlet lets you run commands or expressions on your PowerShell scripts. This method can be used to run complex commands and scripts that involve exe files. The command syntax for Invoke-Expression is as follows:

				
					Invoke-Expression -Command "Path_to_exe\yourfile.exe"
				
			

For example, using ‘myfile.exe’ on your C:\ drive again, you can run it as follows:

				
					Invoke-Expression -Command "C:\myfile.exe"
				
			

The Start-Process cmdlet

With the Start-Process cmdlet, you can start one or more processes on the local computer. Being a more modern method, the use of Start-Process cmdlet helps when you need to run an exe file with additional switches or start in a specific directory, in a new window, or with different credentials.

Here’s a basic example of how to use the Start-Process cmdlet:

				
					Start-Process -FilePath "Path_to_exe\yourfile.exe"
				
			

For example:

				
					Start-Process -FilePath "C:\myfile.exe"
				
			

Start-Process also pulls some extra weight. For example, you can use Start-Process to run an exe file in a new window:

				
					Start-Process -FilePath "C:\myfile.exe" -NoNewWindow
				
			

Running EXE files with arguments

You often need to add arguments when calling an EXE file. Thankfully, it’s easy to do this with PowerShell. You simply include the arguments within the command. Here’s how that would look using the call operator:

				
					& "Path_to_exe\yourfile.exe" -argument
				
			

For the Start-Process cmdlet, you use the -ArgumentList parameter:

				
					Start-Process -FilePath "Path_to_exe\yourfile.exe" -ArgumentList "-argument"
				
			

Conclusion

PowerShell commands and scripts offer a high level of control over Windows and other applications. With the robust functionalities of PowerShell, you can run EXE files in different ways depending on your needs.

While the examples in this guide provide basic techniques, remember that the actual commands used can vary depending on the specific EXE file being called and the use case. Make sure to always reference the software’s manual or online guides to find the correct command lines and switches.

PowerShell is a powerful tool in your IT toolbox. By knowing how to run EXE files in PowerShell, you’re one step closer to fully leveraging its capabilities.

Was this article helpful?

Sorry about that...

What could we improve?

Thank you for your Feedback!

Table of Contents

XEOX - Streamline your IT management with ease

The ultimate IT Administration Tool

Optimized patch management, secure remote access, seamless software deployment, task automation and scripting and a comprehensive CMDB to keep an eye on your IT assets.

Recent Posts

Subscribe to our Newsletter

Get the latest news about current IT-Trends & more AND get a free E-Book: Essential IT Security Practices

BLACK WEEK Special at XEOX!

This is your chance to make the most of our special deal and transform your experience with our services. 

Our Black Week Special at XEOX kicks off today!

20% Discount

 on your First Year Subscription!

From November 20th to November 27th, we are offering an incredible 20% off on all new subscriptions for the first year.

Whether you’ve been considering joining the XEOX family or looking for an opportunity to save, now is the perfect time.