How to Launch and Close an Application using Powershell to Complete an Install

Background:

I recently scripted a nightmare app where its install could only be completed if users navigated to the launch exe and ran it as an administrator. The reason is that whoever built the install forgot to add a COM object registration in the main installer package, so they added the bandaid fix to the launch exe. Besides the hassle of having to run the launch.exe once as an admin, there was the problem of users not having local admin rights.

I ended up putting together a SCCM task sequence to install the application, which includes a “Run Powershell Script” task to run the launch exe once as the local admin, pause, then close.

Steps:

In SCCM go to Operating Systems – Task Sequences

Right click and choose Create Task Sequence

Type in a name for the TS.

In the editor, click Add – Software – Install Application. Click the sun icon and navigate to the application you scripted and published.

Next add a “Run Powershell Script” task:

Add the following powershell script by clicking “Edit Script….”

The ps1 script is:

[box style=”1]

$StartProcInfo = new-object system.Diagnostics.ProcessStartInfo

$StartProcInfo.FileName = ‘C:\Program Files\MicroSurvey\StarNet 9\StarNet.exe’

$process = [System.Diagnostics.Process]::Start($StartProcInfo)

Sleep 5

$process.kill()

[/box]

The most important step is to have this script run by a local admin account that doesn’t change.

Click set:

Click Apply – OK

Create a deployment to your test machine and launch through Software Center. Test the app as you won’t see the launch script through the running of the TS.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.