16 July 2015

Running Programs as an Application Installation in SCCM 2012

Recently, I had to deploy an application, IntApp, with minimal intrusion and no reboots. Part of the process was to restart the application after a successful installation. The crux was that the application has to run under the user credentials. The app starts every time a system is logged into, but with laptops, that could have been a long time until the user actually rebooted the machine. This could also have been done as a package in which the executable would have been executed, but I wanted verification that when it was executed, it was actually running. To achieve this, I wrote two powershell scripts. The first one is the detection method and the second is the one that actually executes the app.

The detection method first makes sure the executable is installed. If it is, it then looks for the process to see if it is running. If it's running, a success is returned to SCCM. If not, nothing is returned back to SCCM, therefor SCCM interprets that as a failure and proceeds to execute the installer. If the application is not installed, it also returns a failure to SCCM.

The installation will test to see if the executable is present. If not, it automatically fail the install with an exit code 1. If it is installed, it will then test for the process. If the process is present, it will return a success code back to SCCM. If it is not, it will then run the executable and retest to make sure it is present in memory.

Here is the detection method:


 $DesktopExtension = $Env:ProgramFiles + "\IntApp\Desktop Extension\IntappTimeDesktopExtension.exe"  
 If ((Test-Path -Path $DesktopExtension) -eq $true) {  
      $ProcessActive = Get-Process -Name IntappTimeDesktopExtension -ErrorAction SilentlyContinue  
      If ($ProcessActive.ProcessName -eq "IntappTimeDesktopExtension") {  
           Write-Host "Success"  
           exit 0  
      } else {  
           exit 0  
      }  
 } else {  
      exit 0  
 }  


Here is the application installation script:


 $DesktopExtension = $Env:ProgramFiles + "\IntApp\Desktop Extension\IntappTimeDesktopExtension.exe"  
 If ((Test-Path -Path $DesktopExtension) -eq $true) {  
      $ProcessActive = Get-Process -Name IntappTimeDesktopExtension -ErrorAction SilentlyContinue  
      If ($ProcessActive.ProcessName -ne "IntappTimeDesktopExtension") {  
           Start-Process -FilePath $env:ProgramFiles"\IntApp\Desktop Extension\IntappTimeDesktopExtension.exe" -ErrorAction SilentlyContinue  
           Start-Sleep -Seconds 2  
      } else {  
           Write-Host "Success"  
           exit 0  
      }  
      $ProcessActive = Get-Process -Name IntappTimeDesktopExtension -ErrorAction SilentlyContinue  
      If ($ProcessActive.ProcessName -eq "IntappTimeDesktopExtension") {  
           Write-Host "Success"  
           exit 0  
      } else {  
           exit 0  
      }  
 } else {  
      exit 1  
 }  
   

Related Posts:

  • Installing Dell CCTK and Configuring BIOS Settings This script will install the Dell CCTK and set specified BIOS settings. Unlike the CCTK that allows you to create a multiplatform file to run against any Dell model machine, this script takes a different approach so that t… Read More
  • Verify SCCM can see Application GUIDs I was deploying an application through SCCM and it continued to fail every time, although the app was completely installed. I knew it had to be with the verification process. I went through and entered all of the GUIDs for … Read More
  • Get list of installed printers This function will get the list of printers installed for a user. It will also get the Default Printer. It outputs the list to Printers.txt, located at the location where the script is executed. You can download the script… Read More
  • Creating Active Setup Registry Key Here is a script I just wrote that will create an active setup registry key. It prompts you for the title, description, command line execution string, and version. It generates a unique GUID to name the registry key. It the… Read More
  • Enable or Disable Internet Explorer Active X Components This script will enable or disable Internet Explorer Active X components. All you have to do is pass the user friendly name of the component, component's GUID, and the flag. The app will verify if the change actually takes … Read More

0 comments:

Post a Comment