Forum Discussion
Correct App detection rule File Path for User Folder
- Jun 27, 2022
Detection rules run as SYSTEM, not as user even if you deploy it as a user package. You have to use something outside a Users folder to detect the installation, I usually create a file in c:\programdata\customername\...\installed.txt and check on that to see if the installation succeeded
I know this is an old thread but I thought I would pass along a custom script that I use for user based installs. This will check if a file exists inside the users profile. (update the file and path and save as a ps1 file):
# BEGIN: Custom Detection Script
$lastLoggedOnUser = (Get-WmiObject -Class Win32_ComputerSystem | Select-Object -ExpandProperty UserName).Split('\')[-1]
$filePath = "C:\Users\$lastLoggedOnUser\changeto\the\path\filename.exe"
if (Test-Path -Path $filePath) {
Write-Host "File exists on the last logged on user's profile directory."
exit 0 # Return success
} else {
Write-Host "File does not exist on the last logged on user's profile directory."
exit 1 # Return failure
}
# END: Custom Detection Script
- TorstenHOct 15, 2024Copper ContributorPerfect, thank you. 🙂