Install Win32 Apps with Scripts embeddet in the .intunewin

Jason Dalby 1 Reputation point
2020-08-21T13:45:28.237+00:00

Hello Community,

i would like to install a Windows App (win32) with a Script which i include in the .intunewin file.

following example Scenario:

I want to install firefox. The Silent install command is firefox.exe /s. The uninstall command & "C:\Program Files\Mozilla Firefox\uninstall\helper.exe" /s. I put these commands in two different ps1 files.

  1. ffinstall.ps1 (for installing firefox)
  2. ffuninstall.ps1 (for uninstalling firefox)

Here are the Steps i do

  1. I put the Firefox.exe and the powershell scripts in one folder called Firefox
  2. With the IntuneWinAppUtil.exe i create a .intunewin file from from the content of the Firefox folder
  3. I create a Windows app (win32) and add the Firefox.intunewin file i created
  4. in the Tab where i add the install Command and Uninstall Commands i use the commands powershell.exe -executionpolicy Bypass -file .\ffinstall.ps1 for the install command and powershell.exe -executionpolicy Bypass -file .\ffuninstall.ps1 for the uninstall command
  5. In the Detection rules i add rule to detect the Registry Entry Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla
  6. I assign the application

After some time the Application fails to Deploy which ist displayd in the Troubleshooting: Error code: 0x87D1041C The application was not detected after installation completed successfully

The Software didnt intstall on the Client. Im trying to Troubleshoot, i researched where the log files are being stored on the client. But there are no Logfiles whatsoever so i can figure out what actually happened. I searched under Micosoft Intune Management Extension but no Logs were created.

I would like to find out where the mistake ist and figure out how to Troubleshoot this issue. I Think this might make deploying executable Software a bit more comfortable. Im tyring to undertand a bit more the idea behind adding Software with Script, because i didnt even knew youre were able to do so.

https://social.technet.microsoft.com/Forums/en-US/b166ad27-dc2e-4e21-b701-53920b2507d7/how-to-use-multiple-uninstallation-commands-for-a-client-app?forum=microsoftintuneprod

Microsoft Intune
Microsoft Intune
A Microsoft cloud-based management solution that offers mobile device management, mobile application management, and PC management capabilities.
4,546 questions
{count} votes

5 answers

Sort by: Most helpful
  1. Ryan Sheldon 6 Reputation points
    2021-04-08T13:37:18.457+00:00

    @Jason Dalby - Change your path so that it uses the formatting for a legacy command, not a PowerShell command. (e.g. remove the ".\" before the file name)

    Example:

    Install Command - powershell.exe -ExecutionPolicy Bypass -File Install-TheThing.ps1
    Uninstall Command - powershell.exe -ExecutionPolicy Bypass -File Uninstall-TheThing.ps1

    YMMV, but this seemed to work fairly well in our limited testing. Good luck!

    1 person found this answer helpful.
    0 comments No comments

  2. Jason Sandys 31,181 Reputation points Microsoft Employee
    2020-08-22T22:32:13.707+00:00
    1. Why would you put firefox.exe /s in a PowerShell script instead of just directly calling it?
    2. I can't tell you why your detection method is not correct. My guess is that you set it up to detect a value but only specified a key (what you have above is a key, not a setting/value).
    3. There definitely should be a log file under the IME folder. See https://www.anoopcnair.com/intune-win32-app-troubleshooting/ for lots of good info.

  3. AndyLiu-MSFT 586 Reputation points
    2020-08-24T03:34:03.86+00:00

    1 Instead of using PowerShell script, you can just use the install and uninstall commands directly in the App configuration settings. Please see the following screenshot for reference.

    19650-image.png

    2 Based on the error code, typically occurs when a user uninstalls an app manually after Intune successfully installed the app. There are other reasons, and you can refer to the error description as below. Please click here for more info.

    19763-image.png

    3 For IME logs, please go to C:\ProgramData\Microsoft\IntuneManagementExtension\Logs. Please just refer to the troubleshooting instructions for Win32 app issues by clicking the following link.

    Troubleshoot Win32 app issues


    If the response is helpful, please click "Accept Answer" and upvote it.


  4. Pavel yannara Mirochnitchenko 12,371 Reputation points MVP
    2021-07-12T05:32:21.313+00:00

    I am transforming all my apps to execute on powershell nativelly (instead of .bat or .cmd), and I have overrun this by using cmd inside the package to call powershell, but I really would like to use native ps command line directly in win32 app.

    0 comments No comments

  5. Andrew Hovering Beard 1 Reputation point
    2023-01-18T12:33:03.83+00:00

    Try using a script that checks for the running process of the installer before it exits maybe like this (not tested but should be ok)? My example uses SCCM client setup.

    Oh yes, you need to package the IntuneWin app using the Powershell script as the installer process to call and have the script in the same folder as the install file(s), e.g.

    IntuneWinAppUtil -c "C:\APP_PACKAGES\SCCMClient" -s "C:\APP_PACKAGES\SCCMClient\InstCcmsetup.ps1" -o "C:\APP_INTUNE" –q

    $Error.Clear()
    
    
    $VerbosePreference = 'Continue'
    $exe = "path\ccmsetup.exe"
    
    Start-Process -FilePath "ccmsetup.exe" -ArgumentList " /nocrlcheck /mp:https://SERVER.WESTEUROPE.CLOUDAPP.AZURE.COM/CCM_Proxy_MutualAuth/12345678912345 CCMHOSTNAME=SERVER.WESTEUROPE.CLOUDAPP.AZURE.COM/CCM_Proxy_MutualAuth/12345678912345 SMSSiteCode=PS2 SMSMP=http://Server.domain.local AADTENANTID=12345678-1234-1234-1234-123456789012 AADCLIENTAPPID=12345678-1234-1234-1234-123456789012 AADRESOURCEURI=api://12345678-1234-1234-1234-123456789012/CMG-ServerApp"
    
    # -------------------------------------------------------------------------------------------------------------------------
    
    $TheProcessName=$exe.split('\')[-1].split('.')[0]
    $MinutesToWait = 20
    $SecondsToWaitBetweenChecking = 15
    
    if ([string]::IsNullOrEmpty((get-process -name $TheProcessName -ErrorAction SilentlyContinue)) | Select-Object -First 1) {
        $ProcessRunning=$False
        }
    else
      {$ProcessRunning=$True}
    
    # Write-Verbose $ProcessRunning
    
    if ($ProcessRunning -eq $True) {
        $TimeStart = ((Get-Process -name $TheProcessName  | Select-Object -First 1).StartTime)
        $TimeEnd = $TimeStart.addminutes($MinutesToWait)
    }
    
    Do {
      $TimeNow = Get-Date
    if ([string]::IsNullOrEmpty((get-process -name $TheProcessName -ErrorAction SilentlyContinue))) {
        $ProcessRunning=$False
        }
    else
      {$ProcessRunning=$True}
    
    #Write-Verbose "TimeNow = $TimeNow, TimeEnd= $TimeEnd, IsProcess Running = $ProcessRunning"
      
    
      if (($TimeNow -ge $TimeEnd) -and ($ProcessRunning -eq $true) ) {
       #Kill the process
        (Get-Process -Name $TheProcessName).Kill()
    #    Write-Verbose "Tried to Kill $TheProcessName"
        }
       else {
        if ($TimeNow -le $TimeEnd) {
    #    Write-Verbose "Not done yet, it's only $TimeNow, process started $TimeStart, if still running after $TimeEnd, we'll kill the process $TheProcessName"
        Start-Sleep -Seconds $SecondsToWaitBetweenChecking
          }
        }
      }
     Until ( ($TimeNow -ge $TimeEnd) -or ($ProcessRunning -eq $False) )
    
    
    
    0 comments No comments