{"id":2832,"date":"2023-09-25T21:45:57","date_gmt":"2023-09-25T13:45:57","guid":{"rendered":"http:\/\/www.jhouseconsulting.com\/?p=2832"},"modified":"2023-09-26T04:45:54","modified_gmt":"2023-09-25T20:45:54","slug":"best-practice-for-the-active-setup-stubpath-value","status":"publish","type":"post","link":"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/2023\/09\/25\/best-practice-for-the-active-setup-stubpath-value-2832","title":{"rendered":"Best Practice for the Active Setup StubPath value"},"content":{"rendered":"<p>It\u2019s been a best practice for a long time to clear the Active Setup StubPath value per application to avoid the Active Setup processes from running at logon, impacting the user experience. This is a challenge we constantly have with Vendors and packaging teams. But blindly clearing the StubPath value could lead to application issues. So what happens when you need to go back and troubleshoot an issue with an application that may be related to what &#8220;should have&#8221; run via the Active Setup process. How do you know what the&nbsp;StubPath value was originally set to? Do you record it somewhere?<\/p>\n<p>I&#8217;ve been running a script for years over my builds that simply renames the existing StubPath value to&nbsp;StubPath.Backup and time stamps it. This way you can always review what it should be, and make the necessary changes to allow for this.<!--more--><\/p>\n<p>The following screen shot shows what the Microsoft Edge StubPath looks like once the script has run.<\/p>\n<p><a href=\"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-content\/uploads\/2023\/09\/Active-Setup-StubPath.png\"><img fetchpriority=\"high\" decoding=\"async\" class=\"aligncenter size-large wp-image-2833\" src=\"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-content\/uploads\/2023\/09\/Active-Setup-StubPath-680x216.png\" alt=\"Active Setup StubPath\" width=\"680\" height=\"216\" srcset=\"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-content\/uploads\/2023\/09\/Active-Setup-StubPath-680x216.png 680w, https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-content\/uploads\/2023\/09\/Active-Setup-StubPath-300x95.png 300w, https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-content\/uploads\/2023\/09\/Active-Setup-StubPath-768x244.png 768w, https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-content\/uploads\/2023\/09\/Active-Setup-StubPath.png 1546w\" sizes=\"(max-width: 680px) 100vw, 680px\" \/><\/a><\/p>\n<p>Notice how the real StubPath value is blank as per best practice, but a second value exists that is a point in time backup of the value? So in this case should we experience issues with Microsoft Edge, I can easily review what the expected value was set to in order to understand if this is the cause of the issue. With this in place there is no stress.<\/p>\n<p>The script enumerates all subkeys from the following keys to process all StubPath values:<\/p>\n<ul>\n<li>HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Active Setup\\Installed Components<\/li>\n<li>HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node\\Microsoft\\Active Setup\\Installed Components<\/li>\n<\/ul>\n<p>I run this as a once of task after all the applications are patches are installed before a build completes, but you can also run it as a computer startup script.<\/p>\n<p>Here is the <a  data-e-Disable-Page-Transition=\"true\" class=\"download-link\" title=\"\" href=\"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/download\/2838\/?tmstv=1776906589\" rel=\"nofollow\" id=\"download-link-2838\" data-redirect=\"false\" >\n\tActive Setup StubPath\t(711 downloads\t)\n<\/a>\n script:<\/p>\n<pre class=\"brush: powershell; auto-links: false; title: ; toolbar: false; notranslate\" title=\"\">\r\n&lt;#\r\n  This script will clear the Active Setup Stubpath values. However, instead of just clearing them,\r\n  it creates a backup of the Stubpath with the time stamp for future reference and troublshooting\r\n  requirements.\r\n\r\n  Script name: ClearActiveSetup.ps1\r\n  Release 1.2\r\n  Written by Jeremy Saunders (jeremy@jhouseconsulting.com) 19th September 2017\r\n  Modified by Jeremy Saunders (jeremy@jhouseconsulting.com) 25th September 2023\r\n\r\n#&gt;\r\n\r\n#-------------------------------------------------------------\r\n\r\n# Set Powershell Compatibility Mode\r\nSet-StrictMode -Version 2.0\r\n\r\n# Enable verbose, warning and error mode\r\n$VerbosePreference = 'Continue'\r\n$WarningPreference = 'Continue'\r\n$ErrorPreference = 'Continue'\r\n\r\n#-------------------------------------------------------------\r\n\r\n$StartDTM = (Get-Date)\r\n\r\n# Get the TEMP path\r\n$logPath = &#x5B;System.IO.Path]::GetTempPath()\r\n$logPath = $logPath.Substring(0,$logPath.Length-1)\r\n\r\n# Set the logpath to C:\\Windows\\Temp\r\n$logPath = &quot;${env:SystemRoot}&quot; + &quot;\\Temp&quot;\r\n\r\n# Get the script name\r\n$ScriptName = &#x5B;System.IO.Path]::GetFilenameWithoutExtension($MyInvocation.MyCommand.Path.ToString())\r\n\r\n$logFile = &quot;$logPath\\$ScriptName.log&quot;\r\n\r\n# Start the transcript\r\ntry {\r\n  Start-Transcript &quot;$logFile&quot;\r\n}\r\ncatch {\r\n  Write-Verbose &quot;$(Get-Date -format &quot;dd\/MM\/yyyy HH:mm:ss&quot;): This host does not support transcription&quot;\r\n}\r\n\r\n#------------------------------------\r\n\r\n# Add strings to this array that may be in StubPaths that you want to be excluded from being cleared.\r\n$Excludes = @()\r\n\r\n$ParentPaths = @(&quot;HKLM:\\SOFTWARE\\Microsoft\\Active Setup\\Installed Components&quot;,&quot;HKLM:\\SOFTWARE\\WOW6432Node\\Microsoft\\Active Setup\\Installed Components&quot;)\r\n$Value = &quot;StubPath&quot;\r\n$BackupValue = &quot;StubPath.Backup-$(Get-Date -format &quot;dd\/MM\/yyyy HH:mm:ss&quot;)&quot;\r\n\r\nForEach ($ParentPath in $ParentPaths) {\r\n  Get-Childitem &quot;$ParentPath&quot; -Recurse -ErrorAction SilentlyContinue | % {\r\n    $ValueExist = $False\r\n    $ErrorActionPreference = &quot;stop&quot;\r\n    Try {\r\n      If ((Get-ItemProperty -Path &quot;$ParentPath\\$($_.PSChildName)&quot; | Select-Object -ExpandProperty &quot;$Value&quot;) -ne $null) {\r\n        $ValueExist = $True\r\n      }\r\n    }\r\n    Catch &#x5B;System.Exception] {\r\n      #$($_.Exception.Message)\r\n    }\r\n    $ErrorActionPreference = &quot;Continue&quot; \r\n    If ($ValueExist) {\r\n      Write-Verbose &quot;`&quot;$Value`&quot; found under `&quot;$ParentPath\\$($_.PSChildName)`&quot;&quot; -verbose\r\n      $BackupValueExist = $False\r\n      $ErrorActionPreference = &quot;stop&quot;\r\n      Try {\r\n        If ((Get-ItemProperty -Path &quot;$ParentPath\\$($_.PSChildName)&quot; | Select-Object -ExpandProperty &quot;$BackupValue&quot;) -ne $null) {\r\n          $BackupValueExist = $True\r\n        }\r\n      }\r\n      Catch &#x5B;System.Exception] {\r\n        #$($_.Exception.Message)\r\n      }\r\n      $ErrorActionPreference = &quot;Continue&quot; \r\n      If ($BackupValueExist -eq $False) {\r\n        $ParentKey = Get-Item -Path &quot;$ParentPath\\$($_.PSChildName)&quot;\r\n        $PropertyValue = $ParentKey.GetValue(&quot;$Value&quot;)\r\n        If ($PropertyValue -ne &quot;&quot;) {\r\n          Write-Verbose &quot;- Value: $PropertyValue&quot; -verbose\r\n          $PropertyType = $ParentKey.GetValueKind(&quot;$Value&quot;)\r\n          $Skip = $False\r\n          ForEach ($Exlude in $Excludes) {\r\n            If ($PropertyValue -Like &quot;*$Exlude*&quot;) {\r\n              $Skip = $True\r\n              Break\r\n            }\r\n          }\r\n          If ($Skip -eq $False) {\r\n            Write-Verbose &quot;- Type: $PropertyType&quot; -verbose\r\n            Write-Verbose &quot;- Renaming to `&quot;$BackupValue`&quot;...&quot; -verbose\r\n            Rename-ItemProperty -Path &quot;$ParentPath\\$($_.PSChildName)&quot; -Name &quot;$Value&quot; -NewName &quot;$BackupValue&quot;\r\n            Write-Verbose &quot;- Creating an empty `&quot;$Value`&quot; value with property type of `&quot;$PropertyType`&quot;...&quot; -verbose\r\n            New-ItemProperty -Path &quot;$ParentPath\\$($_.PSChildName)&quot; -Name &quot;$Value&quot; -PropertyType $PropertyType -Value &quot;&quot;  Force | Out-Null\r\n          } Else {\r\n            Write-Verbose &quot;- This $Value value has been excluded. No action will be taken.&quot; -verbose\r\n          }\r\n        } Else {\r\n          Write-Verbose &quot;- The value is empty. No action will be taken.&quot; -verbose\r\n        }\r\n      } Else {\r\n        Write-Verbose &quot;- The `&quot;$BackupValue`&quot; value already exists.&quot; -verbose\r\n      }\r\n    }\r\n  }\r\n}\r\n\r\n#------------------------------------\r\n\r\nWrite-Verbose &quot;Stop logging&quot; -Verbose\r\n$EndDTM = (Get-Date)\r\nWrite-Verbose &quot;Elapsed Time: $(($EndDTM-$StartDTM).TotalSeconds) Seconds&quot; -Verbose\r\nWrite-Verbose &quot;Elapsed Time: $(($EndDTM-$StartDTM).TotalMinutes) Minutes&quot; -Verbose\r\n\r\n# Stop the transcript\r\ntry {\r\n  Stop-Transcript\r\n}\r\ncatch {\r\n  Write-Verbose &quot;$(Get-Date -format &quot;dd\/MM\/yyyy HH:mm:ss&quot;): This host does not support transcription&quot;\r\n}\r\n<\/pre>\n<p>Enjoy!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It\u2019s been a best practice for a long time to clear the Active Setup StubPath value per application to avoid the Active Setup processes from running at logon, impacting the user experience. This is a challenge we constantly have with Vendors and packaging teams. But blindly clearing the StubPath value could lead to application issues. &#8230; <a title=\"Best Practice for the Active Setup StubPath value\" class=\"read-more\" href=\"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/2023\/09\/25\/best-practice-for-the-active-setup-stubpath-value-2832\" aria-label=\"Read more about Best Practice for the Active Setup StubPath value\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"footnotes":""},"categories":[554,14,626,388,659,5,91,38,242],"tags":[700,702,703,701],"class_list":["post-2832","post","type-post","status-publish","format-standard","hentry","category-best-practice","category-citrix","category-cvad","category-mdt","category-powershell","category-scripting","category-vdi","category-xenapp","category-xendesktop","tag-active-setup","tag-hkey_local_machinesoftwaremicrosoftactive-setupinstalled-components","tag-hkey_local_machinesoftwarewow6432nodemicrosoftactive-setupinstalled-components","tag-stubpath"],"aioseo_notices":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-json\/wp\/v2\/posts\/2832","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-json\/wp\/v2\/comments?post=2832"}],"version-history":[{"count":5,"href":"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-json\/wp\/v2\/posts\/2832\/revisions"}],"predecessor-version":[{"id":2848,"href":"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-json\/wp\/v2\/posts\/2832\/revisions\/2848"}],"wp:attachment":[{"href":"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-json\/wp\/v2\/media?parent=2832"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-json\/wp\/v2\/categories?post=2832"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-json\/wp\/v2\/tags?post=2832"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}