DrixlRey
DrixlRey

Reputation: 245

Using Start-Process to call a .bat file that calls an .exe, wrong path?

On PowerShell when I issue the command Start-Process c:\Folder\install.bat.

The batch file has this inside:

setup.exe /switch1 /switch2

When I run install.bat on its own, it runs fine. My problem is when I am calling it from PowerShell I notice it is trying to run setup.exe from the path systems32, and it says command not recognized.

How do I run PowerShell and give the correct path to where to run setup.exe? I tried to place a path inside the batch file, unsuccessfully.

Upvotes: 0

Views: 860

Answers (1)

user6811411
user6811411

Reputation:

I guess setup.exe started with a path will miss some files present in the current folder. So this might be a PoSh way

Set-Location c:\Folder\
Start-Process setup.exe /switch1 /switch2

Or inside the batch change the current directory

Pushd %~dp0
setup.exe /switch1 /switch2
popd

HTH

Upvotes: 1

Related Questions