0

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

rhp30
  • 11
  • 5

1 Answers1

0

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
}
Daniel Mann
  • 57,011
  • 13
  • 100
  • 120
  • Thanks @Daniel. But I also wanted to check if we have pre-defined variables in TFS vNext Build tasks so that i can do something as follows: if (Test-Path 'C:\Program Files\Altiris\Altiris Agent\AexAgentUtil.exe') { # run uninstall vnext task } else { # run install vnext task } – rhp30 Feb 13 '19 at 20:10
  • @rk30 Variables can be accessed in your script. Refer to the documentation. – Daniel Mann Feb 13 '19 at 21:53