Powershell

How to Run an exe File in PowerShell With Parameters With Spaces and Quotes

PowerShell is the most powerful scripting tool in Windows that can perform several unorthodox tasks that other applications normally can not do. It can execute or run the “exe” file using specific cmdlets. Moreover, additional parameters are also utilized side by side while running an executable file in PowerShell.

This post will explain the procedure to run an “exe” file in PowerShell.

How to Run/Execute an exe File With Parameters With Spaces and Quotes in PowerShell?

These are the methods that can be used to execute the “exe” file”:

Method 1: Run an exe File With Parameters With Spaces and Quotes Using “Start-Process” Command in PowerShell

The first method to run the “exe” file is to use the “Start-Process” command in PowerShell. It is used to initiate one or more processes.

Example

Now, execute the provided command in PowerShell:

> Start-Process -FilePath "C:\Windows\System32\notepad.exe" -Wait -WindowStyle Maximized

In this above-given command:

  • First, we have utilized the “Start-Process” command to start a specific process.
  • After that, specify the location of the “exe” file using the “-FilePath” parameter.
  • -Wait” parameter waits for a certain process before accepting a new input.
  • -WindowStyle” parameter with the value “Maximized” is used to maximize a certain process/application window:

As a result, the specified exe file will be executed.

Method 2: Run an exe File in PowerShell With Parameters With Spaces and Quotes Using Call Operator (&)

The “Call operator” (&) is also known as the invoke operator, as it is used to execute the program or a file from a specific directory.

Example

To utilize the Call operator for executing the selected exe file, run this command:

> & "C:\Program Files (x86)\VideoLAN\VLC\vlc.exe" "C:\Users\Muhammad Farhan\Music\Song.m4a" /fullscreen

Here:

  • First, we have added the invocation/call operator “&” to initialize the certain app/process.
  • After that, mention the location of the exe file within the inverted commas.
  • Then, we provided the audio file path to play on the “EXE” software.
  • /fullscreen” parameter is used to open the specified VLC executable file in full-screen mode:

When this code is executed, it will run the third-party video player and play the specified file in full-screen mode.

Conclusion

The “exe” file can be executed using two methods, including “Start-Process” and “Call Operator &”. In the first method, first, write the “Start-Process” cmdlet and then add the file path to run it. In the second method, first, write the call operator “&” and add the exe file path. Moreover, you can also add the parameters to run the executable file with additional functions. This post has provided several methods to run the “exe” file with parameters, spaces, and quotes.

About the author

Muhammad Farhan

I am a Computer Science graduate and now a technical writer who loves to provide the easiest solutions to the most difficult problems related to Windows, Linux, and Web designing. My love for Computer Science emerges every day because of its ease in our everyday life.