Add -PerUser support to Register-ADTDll, Unregister-ADTDll and Invoke-ADTRegSvr32#3
Closed
Tom Plant (pl4nty) wants to merge 2 commits into
Closed
Add -PerUser support to Register-ADTDll, Unregister-ADTDll and Invoke-ADTRegSvr32#3Tom Plant (pl4nty) wants to merge 2 commits into
Tom Plant (pl4nty) wants to merge 2 commits into
Conversation
…-ADTRegSvr32. Adds a -PerUser switch that performs per-user DLL registration via regsvr32.exe /n /i:user, calling the DLL's DllInstall entry point so registration data is written to HKCU instead of HKLM. When invoked under the SYSTEM account, regsvr32.exe is executed in the context of the currently logged on user via Start-ADTProcessAsUser so the registration lands in the correct user hive. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
… guards Signed-off-by: Tom Plant <tom.plant@devicie.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request
Description
Adds a
-PerUserswitch toRegister-ADTDll,Unregister-ADTDllandInvoke-ADTRegSvr32to support per-user COM registration.The switch appends
/n /i:userto the regsvr32.exe arguments, which skipsDllRegisterServerand instead calls the DLL'sDllInstallentry point with the'user'argument so registration data is written to HKCU rather than HKLM. This is required for DLLs that support per-user registration (e.g. the Microsoft Teams meeting add-in loader) when deploying without machine-wide registration.Because deployments typically run as SYSTEM — where HKCU writes would land in SYSTEM's own hive — the function detects a SYSTEM caller and executes regsvr32.exe in the context of the currently logged on user via
Start-ADTProcessAsUser, mirroring the existing pattern inSet-ADTActiveSetup. If no user is logged on, a clearNoActiveUserErroris thrown rather than silently registering into the wrong hive.Note: the DLL must export
DllInstallwith per-user support for this to work; this is documented in the comment-based help.Type of change
Checklist
srcand all three functions parse and execute — script-only change, no build pipeline impact expected)How Has This Been Tested?
Tested locally on Windows 11 (PowerShell 7.6.3, non-elevated) against
Microsoft.Teams.AddinLoader.dll(x64), which supports per-user registration viaDllInstall:Register-ADTDll -FilePath <dll> -PerUser -WhatIf— confirmed no registry changes are made (SupportsShouldProcesshonoured).Register-ADTDll -FilePath <dll> -PerUser— confirmedHKCU\Software\Classes\CLSID\{19A6E644-14E6-4A60-B8D7-DD20610A871D}\InprocServer32was written pointing at the specified DLL.Unregister-ADTDll -FilePath <dll> -PerUser— confirmed the HKCU registration was removed.The SYSTEM code path (
Start-ADTProcessAsUserhand-off) follows the established pattern fromSet-ADTActiveSetupbut has not been exercised under a SYSTEM session locally.🤖 Generated with Claude Code