Application Packaging, PowerShell

Running an .exe from a path with a wildcard in PowerShell

It’s been a while since I have posted anything and there is no shortage of topics for me to catch up on. I am going to start with a problem I was working on the last couple of days. Here is the scenario:

I was tasked with packaging the installation of an application that was previously installed manually by the users of the environment I am working in. When the users installed the application from the vendor’s website it would get installed in each user’s appdata folder. The version I was given to package was designed as a per-system install. They also wanted me to remove the per-user install before installing the new per-system version. After creating the package for the new version, the issue became being able to uninstall the per-user version. The install was not an MSI and the vendor’s method for uninstalling was an uninstall.exe file located in the appdata folder where the application had been installed for the user. This is obviously tricky because depending on which user installed the application it could be located in any random user’s folder path. I’ve been using PowerShell for my primary scripting language for most application deployments for some time now, so the key was finding a way to do this in PS. My solution was as follows:

powershell_5-0_icon

First I set a variable for the path with my wildcard. I used the cmdlet resolve-path so that the variable would have the value of whichever user had installed the application I was trying to uninstall by searching for the uninstall.exe in the application folder.

$AppUserPath = Resolve-Path "C:\users\*\AppData\Local\AppVendor\AppName\Uninstall.exe"

Then I created an if statement that would test for the resolved path if it existed and the remove it


If (Test-Path $AppUserPath) { Start-Process -FilePath $AppUserPath -ArgumentList "/S"}

So all together it looked like this:


$AppUserPath = Resolve-Path "C:\users\*\AppData\Local\AppVendor\AppName\Uninstall.exe"
If (Test-Path $AppUserPath)
{Start-Process -FilePath $AppUserPath -ArgumentList "/S"}

So now when my script runs, it will parse through all the user appdata folders on the machine and find the one with the application installed that has uninstall.exe file. Then it will execute the uninstall.exe file using the resolved path that it found. After that installing the new per-system version was a piece of cake

Amber, Application Packaging, How-To Guides, Software Installation Guides

Lync 2013 Basic Deployment

These instructions are for Microsoft Lync 2013 Basic which has fewer features than Lync 2013 Full. However the basic concept will work for both versions.

Step 1 – Extract files from the Lync Basic installer: %sourcelocation%\lyncentry.exe /extract:%extractionlocation%

Step 2 – From the extracted files run the OCT tool: %extractionlocation%\setup.exe /admin

Step 3 – Use OCT to configure a msp file to your desired customization choices.

Step 4 – To avoid the “First things first” window when user start Lync for the first time add the following reg entries under Additional Content | Add Registry Entries in the OCT tool

lync step5a

lync step5b

Step 5 – Save your settings to your MSP file.

Step 6 – Deploy your MSP. How you deploy is up to you:

  • You can add the MSP file you create to the Updates folder of the extracted files from the source installer and run the install with the command %extractionlocation%\setup.exe. This will install all the msp in the Updates folder including your custom MSP. You will see a Microsoft setup window for a second as it reads the MSP file before installing.
  • You can save the MSP to whatever place you like and use a command that will point to that place; %extractionlocation%\setup.exe /adminfile %yourcustomMSPlocation%