if uninstall.exe exists run Uninstall step else jump to Install vNext build task

236 Views Asked by At

I have a release TFS build which has uninstall and install step of an application in my agent folder for further testing. Unfortunately, when it happens to be fresh install in the agent directory it fails with error "Uninstall' is not recognized as an internal or external command".

In this case, I want to run a script in the batch or command line task to check if uninstall.exe is present before running the Uninstall task. Is there any way where I can call Uninstall or Install step according to the If condition in my script?

for an example if exist "C:\Program Files\Altiris\Altiris Agent\AexAgentUtil.exe" goto task1 else task2

Thanks in advance

1

There are 1 best solutions below

2
Daniel Mann On

Don't do it with a batch script or command line, use PowerShell; that's what PowerShell was designed for.

if (Test-Path 'C:\Program Files\Altiris\Altiris Agent\AexAgentUtil.exe') {
   # do something
}
else {
   # do something else
}