I need to detect if an application is already installed in sccm. i have searched that i can use a custom script that does de test and returns the status of the installation depending on the exit-code of the script.
I have and .exe that does this validation, I have created this powershell script that executes de .exe and returns true or false.
$program = ".\teststatus.exe"
$programArgs = "/output" , "console", "STATUS"
Invoke-Command -ScriptBlock { & $program $programArgs }
$LASTEXITCODE
if ($LASTEXITCODE -eq "0")
{
$true
}
else
{
$false
}
!!this .exe is included on the files of the application!!
¿My question is what path I must set in the variable $program that contain the location of the .exe in other to execute it?
SCCM Applications (as opposed to Packages) can use PowerShell scripts to detect whether an application is installed. The problem you will run into is that there is no reliable way to ensure that your detection .exe will be available on the target computer.
It won't help for your detection .exe to be part of the Content for the Application because the Content is not downloaded to the client until the detection logic concludes "not detected".
I think you will be better off finding a way to detect the application without the .exe using either core PowerShell or the built-in detection methods.