Intune App installation of exe with a variable

I have an old application I am trying to deploy to users through the Company Portal.
I created the PSADT installation and works fine locally, but when trying to install from the Company Portal it fails.

My script:

    #endregion
    ##* Do not modify section above
    ##*===============================================
    ##* END VARIABLE DECLARATION
    ##*===============================================

    If ($deploymentType -ine 'Uninstall' -and $deploymentType -ine 'Repair') {
        ##*===============================================
        ##* PRE-INSTALLATION
        ##*===============================================
        [String]$installPhase = 'Pre-Installation'

        ## Show Welcome Message, close Internet Explorer if required, allow up to 3 deferrals, verify there is enough disk space to complete the install, and persist the prompt
        Show-InstallationWelcome  -CheckDiskSpace -PersistPrompt

        ## Show Progress Message (with the default message)
        #Show-InstallationProgress

        ## <Perform Pre-Installation tasks here>
        #[Environment]::SetEnvironmentVariable("IDAHOTECH_INSTALL_DIR", $dirFiles, "Machine")
        #[Environment]::SetEnvironmentVariable("IDAHOTECH_INSTALL_DIR", $dirFiles, "User")
        #$env:IDAHOTECH_INSTALL_DIR = $dirFiles

        # Define the content of the Setup ISS file
$setupiss = @"
[InstallShield Silent]
Version=v6.00.000
File=Response File
[File Transfer]
OverwrittenReadOnly=NoToAll
[{8F07FAB0-5BBA-43EF-979E-6E7C9E4F811E}-DlgOrder]
Dlg0={8F07FAB0-5BBA-43EF-979E-6E7C9E4F811E}-SdWelcome-0
Count=7
Dlg1={8F07FAB0-5BBA-43EF-979E-6E7C9E4F811E}-SdLicense-0
Dlg2={8F07FAB0-5BBA-43EF-979E-6E7C9E4F811E}-SdComponentTree-0
Dlg3={8F07FAB0-5BBA-43EF-979E-6E7C9E4F811E}-SdAskDestPath-0
Dlg4={8F07FAB0-5BBA-43EF-979E-6E7C9E4F811E}-AskOptions-0
Dlg5={8F07FAB0-5BBA-43EF-979E-6E7C9E4F811E}-AskYesNo-0
Dlg6={8F07FAB0-5BBA-43EF-979E-6E7C9E4F811E}-SdFinishReboot-0
[{8F07FAB0-5BBA-43EF-979E-6E7C9E4F811E}-SdWelcome-0]
Result=1
[{8F07FAB0-5BBA-43EF-979E-6E7C9E4F811E}-SdLicense-0]
Result=1
[{8F07FAB0-5BBA-43EF-979E-6E7C9E4F811E}-SdComponentTree-0]
szDir=C:\Program Files (x86)\Roche\LightCycler480
Component-type=string
Component-count=2
Component-0=Main App
Component-1=Adobe-Acrobat
Result=1
[{8F07FAB0-5BBA-43EF-979E-6E7C9E4F811E}-SdAskDestPath-0]
szDir=C:\Program Files (x86)\Roche\LightCycler480
Result=1
[{8F07FAB0-5BBA-43EF-979E-6E7C9E4F811E}-AskOptions-0]
Result=1
Sel-0=1
Sel-1=1
[Application]
Name=LightCycler  480
Version=1.5.1
Company=Roche
Lang=0009
[{8F07FAB0-5BBA-43EF-979E-6E7C9E4F811E}-AskYesNo-0]
Result=0
[{8F07FAB0-5BBA-43EF-979E-6E7C9E4F811E}-SdFinishReboot-0]
Result=1
BootOption=0
"@

        # Save the content to a file with .iss extension
        $setupiss | Out-File -FilePath "$dirFiles\setup.iss" -Encoding ASCII -Force

        ##*===============================================
        ##* INSTALLATION
        ##*===============================================
        [String]$installPhase = 'Installation'

        ## <Perform Installation tasks here>
        $env:IDAHOTECH_INSTALL_DIR = $dirFiles
        Execute-Process -Path "Setup.exe" -Parameters "-s"

        ##*===============================================
        ##* POST-INSTALLATION
        ##*===============================================
        [String]$installPhase = 'Post-Installation'

        ## <Perform Post-Installation tasks here>
        Copy-File -Path "$dirFiles\Roche\*" -Destination "$envProgramData\Roche" -Recurse

        ## Display a message at the end of the install

It is this $env:IDAHOTECH_INSTALL_DIR = $dirFiles variable that the .exe needs. If that is not present, the EXE fails and tells you the “IDAHOTECH_INSTALL_DIR” is missing.

I think when installing it through company portal, it does not work this way with setting the env. I also tried with the system variables:
#[Environment]::SetEnvironmentVariable(“IDAHOTECH_INSTALL_DIR”, $dirFiles, “Machine”)
#[Environment]::SetEnvironmentVariable(“IDAHOTECH_INSTALL_DIR”, $dirFiles, “User”)
But that didn’t work either (commented out after trying the other method).

Perhaps someone here has an idea?

Thanks!

Here is a log:

<![LOG[[Pre-Installation] :: Evaluating disk space requirements.]LOG]!><time="13:38:26.75060" date="02-21-2024" component="Show-InstallationWelcome" context="NT AUTHORITY\SYSTEM" type="1" thread="5456" file="Deploy-Application.ps1">
<![LOG[[Pre-Installation] :: Retrieving free disk space for drive [C:].]LOG]!><time="13:38:26.76160" date="02-21-2024" component="Get-FreeDiskSpace" context="NT AUTHORITY\SYSTEM" type="1" thread="5456" file="Deploy-Application.ps1">
<![LOG[[Pre-Installation] :: Free disk space for drive [C:]: [352013 MB].]LOG]!><time="13:38:26.78060" date="02-21-2024" component="Get-FreeDiskSpace" context="NT AUTHORITY\SYSTEM" type="1" thread="5456" file="Deploy-Application.ps1">
<![LOG[[Pre-Installation] :: Successfully passed minimum disk space requirement check.]LOG]!><time="13:38:26.79760" date="02-21-2024" component="Show-InstallationWelcome" context="NT AUTHORITY\SYSTEM" type="1" thread="5456" file="Deploy-Application.ps1">
<![LOG[[Installation] :: variable is set to C:\Windows\IMECache\b9b5d72e-19c3-4a9c-961c-776c59c4a43b_1\Files]LOG]!><time="13:38:26.81260" date="02-21-2024" component="Deploy-Application" context="NT AUTHORITY\SYSTEM" type="1" thread="5456" file="Deploy-Application.ps1">
<![LOG[[Installation] :: [Setup.exe] successfully resolved to fully qualified path [C:\Windows\IMECache\b9b5d72e-19c3-4a9c-961c-776c59c4a43b_1\Files\Setup.exe].]LOG]!><time="13:38:26.83260" date="02-21-2024" component="Execute-Process" context="NT AUTHORITY\SYSTEM" type="1" thread="5456" file="Deploy-Application.ps1">
<![LOG[[Installation] :: Working Directory is [C:\Windows\IMECache\b9b5d72e-19c3-4a9c-961c-776c59c4a43b_1\Files].]LOG]!><time="13:38:26.85160" date="02-21-2024" component="Execute-Process" context="NT AUTHORITY\SYSTEM" type="1" thread="5456" file="Deploy-Application.ps1">
<![LOG[[Installation] :: Executing [C:\Windows\IMECache\b9b5d72e-19c3-4a9c-961c-776c59c4a43b_1\Files\Setup.exe -s]...]LOG]!><time="13:38:26.85660" date="02-21-2024" component="Execute-Process" context="NT AUTHORITY\SYSTEM" type="1" thread="5456" file="Deploy-Application.ps1">
<![LOG[[Installation] :: Execution completed successfully with exit code [0].]LOG]!><time="13:38:28.94260" date="02-21-2024" component="Execute-Process" context="NT AUTHORITY\SYSTEM" type="1" thread="5456" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: Copying file(s) recursively in path [C:\Windows\IMECache\b9b5d72e-19c3-4a9c-961c-776c59c4a43b_1\Files\Roche\*] to destination [C:\ProgramData\Roche].]LOG]!><time="13:38:28.95460" date="02-21-2024" component="Copy-File" context="NT AUTHORITY\SYSTEM" type="1" thread="5456" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: File copy completed successfully.]LOG]!><time="13:38:28.96360" date="02-21-2024" component="Copy-File" context="NT AUTHORITY\SYSTEM" type="1" thread="5456" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: Bypassing Close-InstallationProgress [Mode: NonInteractive]]LOG]!><time="13:38:28.97960" date="02-21-2024" component="Close-InstallationProgress" context="NT AUTHORITY\SYSTEM" type="1" thread="5456" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: LC480 Installation completed with exit code [0].]LOG]!><time="13:38:29.00660" date="02-21-2024" component="Exit-Script" context="NT AUTHORITY\SYSTEM" type="1" thread="5456" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: -------------------------------------------------------------------------------]LOG]!><time="13:38:29.00960" date="02-21-2024" component="Exit-Script" context="NT AUTHORITY\SYSTEM" type="1" thread="5456" file="Deploy-Application.ps1">

I added a write log to see if the variable is set correctly, and it seems it does. But the installation fails anyway. No idea why?!

Three thoughts that spring to mind:

  1. In what context are you doing the installation (User or System)?
    I suspect if you are deploying in the User context some of that may not work due to the rights the user has on their device (That may be why you were unable to set the machine environment variable)

  2. I’m not sure if in the user context the Setup ISS file could be generated into that path (user might not have write permissions to C:\Windows\IMECache\<Intune_Application_GUID>\ - Why don’t you create this static file and bundle it up with the Intunewin file in the Files sub-directory?
    That way the file will always exist within the deployment correctly . You can then remove the definition of $setupiss and writing this to a file within your Deploy-Application.ps1

  3. Logging - if you write debug information to a log file, you might be able to determine what is going on - This might be of use:
    How to Log built-in PowerShell commands (non-PSADT commands)

Update - Sorry your updated post with the logging overlapped with my post - ignore the logging comment

1 Like

Good question!

  1. I was deploying it as Admin, also tried User.

  2. I write that file cause for the uninstall I need another iss file and the name is the same. The writing to that directory works, I see it get created. Did not check if it had any content though, let me confirm that.
    Or the setup.exe does not have permission to read it? Though the app itself needs admin rights…which makes me believe it can read it.

  3. Yes, i tried as you already noticed :wink:

Oh my. I have no idea why, I tried so many times. But it looks like it works in the User mode from intune.
Not sure what changed in the script :sweat_smile:

So, If you are deploying as Admin (I’ll have to assume you mean SYSTEM?)
What is the Install command line you have configured in Intune for this deployment?
I’m wondering if maybe the application is showing a message that is not being shown to you as this will appear in the SYSTEM context (not the logged on users context).
By using ServiceUI.exe you could see if this resolves the issue
(this may help: Installation messages using ServiceUI.exe in Intune - #3 by Adrian_Scott)

Funny, now it doesn’t work. And like you mentioned, in User mode it can’t write to the directory.
I wonder if I can rename files.

Probably can’t rename in user context due to the same permissions issue on the folder structure

Yeah I figured.
This install file is more then 10 years old. Had to figure out all the silent stuff and respose files.
Finally found out how to specify the answer file, so now I create a setup.iss (default name for the /s parameter) and an uninstall.iss.
I had to use the /f1 parameter (/f1"path to iss").
Been at this for days.

Now to try this with intune.

Are you trying to set these variables during AutoPilot /ESP or as a “on Demand” app?

I use a PS script to create Environment Variables with PowerShell during AutoPilot /ESP BEFORE any Win32app packages with PSADT are run.

In my situation, NONE of the environment variables I create get fully set because the Intune Management Engine (IME) does not deal with user32.dll’s SendMessageTimeout function’s call. This is a function that tells running processes to check for new Environment Variables. In this situation, IME ignores the call. It a bug in IME.

In your situation, you might have to create the Environment Variables, reboot, then install your app.

Its on demand, so when a user needs an app it opens the Company Portal and can select what to install.

I finally found the culprit.
It was the Setup.exe writing the log to the same directory, which is not possible in User context. Again had to find out how to write the log to Temp, I did, and that did the trick. It finally installs.
Thanks for all the tips guys!

2 Likes

Glad you got there in the end.
Well done for your patience :clap:

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.