Jun 27 2022 07:07 AM
Hi Guys,
I have deployed a file to the user's folder, but I don't think I have the correct syntax for the "Current User", I have tried:
%username%
%userprofile%
But Intune doesn't like them as it is showing that it has failed even though it has deployed the file in the correct folder. Below is the detection rule file path. Does anyone know what the correct syntax for the current user is? Many thanks, Tung
Jun 27 2022 07:48 AM - edited Jun 27 2022 07:52 AM
SolutionDetection 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
Jun 27 2022 07:56 AM
@Harm_Veenstra Ahh makes sense. No wonder I couldn’t find much documentation on it. Do you have any doc that states the detection rule is on the system level? And thanks for the tip too!
Jun 27 2022 08:25 AM - edited Jun 27 2022 08:56 AM
It doesn't really mention it on https://docs.microsoft.com/en-us/mem/intune/apps/apps-win32-add#step-4-detection-rules , but it's just the way it works I'm afraid (Many people ask for user level detection rules).
Please mark my answer as solution to mark it as solved.
Jun 27 2022 08:30 AM
Oct 30 2022 05:16 PM
Hi@TungNguyen1600 ,
I have exactly the same VPN client to deploy in Intune but none of my scripts/win32app worked.
Would you mind sharing your settings please?
Thanks
Giuliano
Oct 30 2022 10:53 PM
I was playing around with a win32app that got installed in the USER context ... ANd just adding a %username% in the detection rule... first it indeed tries to find it as system
Of course that would just fail
But it seems it also tries to find it as user if the system detection fails... and by the looks of it ... it succeeds
Oct 30 2022 11:02 PM
Oct 30 2022 11:07 PM
Oct 31 2022 08:19 AM
Oct 31 2022 02:09 PM
Hello @Rudy_Ooms_MVP ,
Thanks for your reply.
I finally made it work!
These are my settings:
And the script is:
As I needed to copy the whole folder.
Interesting is if I set the install behaviour as System context, Intune will create another "user" (in users folder) with the device's name.
Thanks a gain!
Giuliano
Oct 31 2022 10:15 PM
Jan 24 2024 01:41 PM
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
Jun 27 2022 07:48 AM - edited Jun 27 2022 07:52 AM
SolutionDetection 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