Custom Install that needs to write to HKCU

Evening all,

I am just curious on the best way to install software that needs to write to HKCU, I have a client that has some software that is custom and they are new to AVD.  I have set them up with FSLogix and multi-session but this one bit of software needs to write to the following locations :

Set-RegistryKey -Key 'HKCU\Software\Microsoft\VSTO\SolutionMetadata\{20770A70-7470-49B6-B565-1FA1398189D5}' -Name 'PreferredClr' -Value 'v4.0.30319' -Type String -SID $UserProfile.SID

        Set-RegistryKey -Key 'HKCU\Software\Microsoft\VSTO\SolutionMetadata\{219EEE1C-85C7-49F9-AC95-CB3BA073FD77}' -Name 'PreferredClr' -Value 'v4.0.30319' -Type String -SID $UserProfile.SID
        Set-RegistryKey -Key 'HKCU\Software\Microsoft\VSTO\SolutionMetadata\{3ED92CF8-2820-4570-A4A8-67DAA4E07E73}' -Name 'PreferredClr' -Value 'v4.0.30319' -Type String -SID $UserProfile.SID
        Set-RegistryKey -Key 'HKCU\Software\Microsoft\VSTO\SolutionMetadata\' -Name 'C:\ProgramData\UpSlide\Binaries\Finance3point1.UpSlide.Excel.vsto' -Value '{20770A70-7470-49B6-B565-1FA1398189D5}' -Type String -SID $UserProfile.SID
        Set-RegistryKey -Key 'HKCU\Software\Microsoft\VSTO\SolutionMetadata\' -Name 'C:\ProgramData\UpSlide\Binaries\Finance3point1.UpSlide.PowerPoint.vsto' -Value '{219EEE1C-85C7-49F9-AC95-CB3BA073FD77}' -Type String -SID $UserProfile.SID
        Set-RegistryKey -Key 'HKCU\Software\Microsoft\VSTO\SolutionMetadata\' -Name 'C:\ProgramData\UpSlide\Binaries\Finance3point1.UpSlide.Word.vsto' -Value '{3ED92CF8-2820-4570-A4A8-67DAA4E07E73}' -Type String -SID $UserProfile.SID


What is the best way to solve this?  I did suggest GPO but they really would like it done another way, they are not using intune as yet otherwise I could have written a run-as-user script.

Any ideas?
 
0

Comments (4 comments)

0
Avatar
Dave Stephenson
(Edited )

Scripted Actions aren't generally a good solution for user registry changes because Scripted Actions run as SYSTEM.

You could do this as a scripted action that creates a scheduled task that runs on user logon.

I'm no PowerShell wizard, but something like this should do what you're wanting.
Do you think the customer would be willing to do that?

$taskName = "ApplyRegistryChangesOnLogon"
$taskDescription = "This task applies registry changes on user logon."
$scriptBlock = @"
    # Apply registry changes
    Set-RegistryKey -Key 'HKCU\Software\Microsoft\VSTO\SolutionMetadata\{20770A70-7470-49B6-B565-1FA1398189D5}' -Name 'PreferredClr' -Value 'v4.0.30319' -Type String -SID $env:USERPROFILE
    Set-RegistryKey -Key 'HKCU\Software\Microsoft\VSTO\SolutionMetadata\{219EEE1C-85C7-49F9-AC95-CB3BA073FD77}' -Name 'PreferredClr' -Value 'v4.0.30319' -Type String -SID $env:USERPROFILE
    Set-RegistryKey -Key 'HKCU\Software\Microsoft\VSTO\SolutionMetadata\{3ED92CF8-2820-4570-A4A8-67DAA4E07E73}' -Name 'PreferredClr' -Value 'v4.0.30319' -Type String -SID $env:USERPROFILE
    Set-RegistryKey -Key 'HKCU\Software\Microsoft\VSTO\SolutionMetadata\' -Name 'C:\ProgramData\UpSlide\Binaries\Finance3point1.UpSlide.Excel.vsto' -Value '{20770A70-7470-49B6-B565-1FA1398189D5}' -Type String -SID $env:USERPROFILE
    Set-RegistryKey -Key 'HKCU\Software\Microsoft\VSTO\SolutionMetadata\' -Name 'C:\ProgramData\UpSlide\Binaries\Finance3point1.UpSlide.PowerPoint.vsto' -Value '{219EEE1C-85C7-49F9-AC95-CB3BA073FD77}' -Type String -SID $env:USERPROFILE
    Set-RegistryKey -Key 'HKCU\Software\Microsoft\VSTO\SolutionMetadata\' -Name 'C:\ProgramData\UpSlide\Binaries\Finance3point1.UpSlide.Word.vsto' -Value '{3ED92CF8-2820-4570-A4A8-67DAA4E07E73}' -Type String -SID $env:USERPROFILE
"@

# Create a Scheduled Task to run the script on user logon
$action = New-ScheduledTaskAction -Execute "PowerShell.exe" -Argument "-Command $scriptBlock"
$trigger = New-ScheduledTaskTrigger -AtLogon
$principal = New-ScheduledTaskPrincipal -UserId "$env:USERNAME" -LogonType Interactive

# Register the scheduled task
Register-ScheduledTask -Action $action -Principal $principal -Trigger $trigger -TaskName $taskName -Description $taskDescription
0
Avatar
Ryan Dorman

Maybe PSADT and Active Setup?

0
Avatar
Dave Stephenson

Great idea, Ryan!
Vince Thompson, is your customer open to utilizing 3rd party tools?

1
Avatar
Vince Thompson

Dave Stephenson Yeah they would be, for now I have done a scheduled task.  Thanks everyone for the suggestions.  

Please sign in to leave a comment.