Search code examples
windowspowershellpowershell-3.0azure-powershellpowershell-4.0

How to use Powershell to run a exe with a wildcard as the directory keeps changing with each install


I am attempting to run a .exe file for an app which is installed but requires to be activated. This would be a fairly easy process but the directory with .exe changes name slightly with each install. For example a number is added to each folder after the install (Different devices have different numbers) e.g. test1 and then test2. How could I use a wild card to target the folder as it changes?

Example code:

Start-Process -FilePath "\C:\ProgramData\app*/test.exe"

Please note: the app is not real, this is just for display purposes.


Solution

  • Your path seems to be incorrect. Wildcards should work in PowerShell. For example, the below wildcard works for me in PowerShell 5.0:

    enter image description here

    Try running Start-Process -FilePath "C:\ProgramData\app*\test.exe"