Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Powershell executing .exe file without the folder path

Tags:

powershell

I am fairly new to powershell and I am trying to create a script that executes a .exe file. I can execute them on my machine no problem because the folder path is hard coded. The problem is that if I shift this script to another computer, the .exe it calls might be located in a different folder structure. Example My computer: D:\Folder1\subfolder\RunMe.exe

Client computer might be D:\RunMe\subfolder\RunMe.exe

I just need it to execute the RunMe.exe no matter where it is. Is there a way to do this in powershell?

like image 828
CM_Heroman Avatar asked May 14 '26 03:05

CM_Heroman


1 Answers

# 1. Get the location of RunMe.exe
$RunMe = Get-ChildItem -Path d:\* -Include RunMe.exe -Recurse;
# 2. Invoke RunMe.exe
Start-Process -FilePath $RunMe[0].FullName -Wait -NoNewWindow;

Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!