• Welcome to Support Forum: Get Support for Patch My PC Products and Services.

Pre-install script for Registry Keys

Started by Matthias Veelaert, August 17, 2022, 02:13:25 AM

Previous topic - Next topic

Matthias Veelaert

I have written a powershell script for the ShareX app so I can choose where the app installs to. To do this I had to create a new folder in the registry and an extra key/value in this folder. Locally when I run this script it works perfectly, it creates the folder and key/value pair and then when I download the ShareX app via the company portal, it downloads to this place. Now I added the script as a pre-install script in PatchMyPC so that whoever decides to download the app, gets it installed to this path. However that is not the case. It installs to the default path again and no registry key/value pair is created on my machine.

The script I wrote is this:
New-Item -Path "HKLM:\Software\ShareX"
Set-ItemProperty -Path "HKLM:\Software\ShareX" -Name "PersonalPath" -Type "string" -Value "C:\ShareX"

Any ideas why this won't work?

Kind regards!

Liviu (Patch My PC)

Hi Matthias,

Was the pre-install script added to ShareX after the app or updated was initially created?
If that is the case, if the app/update was already created, it was created without the script in the content for it.
You would have to delete and the re-create the app/update.

Matthias Veelaert

It was indeed added after the app was created. How would I do that. Just unassign the app and also uncheck the app, republisjh delete it in intune and then republish it again to intune?

Andrew Jimenez (Patch My PC)

Hi Matthias,

You should be able to right click the app in the Patch My PC interface, and choose to "Republish" the app during the next sync schedule, then run a sync.