You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

UFT 12.5操作HKLM注册表项时遇Invalid root错误求助

Fixing "Invalid root in registry key" when modifying HKLM Winlogon keys in UFT 12.5 (Windows Server 2012)

Hey there, let's get to the bottom of that registry write error you're hitting. The issue boils down to two key things: UFT 12.5 being a 32-bit application, and Windows Server 2012's registry redirection behavior. Here's what's happening and how to fix it:

Why the error occurs

UFT 12.5 runs as a 32-bit program, so when you try to write to HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon, Windows automatically redirects your request to the 32-bit registry hive (HKLM\SOFTWARE\Wow6432Node\...). But the Winlogon keys you're targeting live in the 64-bit section of the registry—hence the "Invalid root in registry key" error.

Solution: Use WMI's StdRegProv class (64-bit registry access)

Instead of relying on WshShell.RegWrite, use the WMI StdRegProv class, which lets you explicitly access the 64-bit registry hive. This avoids redirection issues and works reliably on Windows Server 2012.

Here's a ready-to-use VBScript snippet for UFT:

' Define constants for registry access
Const HKEY_LOCAL_MACHINE = &H80000002
Const REG_SZ = 1

' Connect to the WMI registry provider
Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")

' Target registry path (no redirection here)
strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"

' Update LegalNoticeCaption
strValueName = "LegalNoticeCaption"
strNewCaption = "Your Custom Caption"
objReg.SetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strNewCaption

' Update LegalNoticeText
strValueName = "LegalNoticeText"
strNewText = "Your full legal notice content goes here"
objReg.SetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strNewText

MsgBox "Registry values updated successfully!", vbInformation

Critical Notes

  • Run UFT as Administrator: Modifying keys under HKLM requires elevated privileges. Right-click the UFT shortcut and select "Run as administrator" before executing the script.
  • Test outside UFT first: If you still hit issues, run the script via cscript.exe (as admin) to confirm it works outside the UFT environment—this helps rule out UFT-specific configuration problems.
  • UAC settings: On Windows Server 2012, UAC might block the operation even for admins, so ensuring elevated rights is non-negotiable.

内容的提问来源于stack exchange,提问作者Vikram Ganapathi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 09:42:40