当用户注销时,在注册表编辑用户配置文件

本文关键字:编辑 用户 配置文件 注册表 用户注销 | 更新日期: 2023-09-27 18:03:39

我需要在注册表中编辑windows用户(域或本地)配置文件,如禁用指定用户的任务管理器。

我在HKey_Users[User SID]…

但是此地址仅在用户登录时存在,一旦用户注销,[SID]树被删除

如果用户没有登录,我怎么做?

当用户注销时,在注册表编辑用户配置文件

您可以使用vbscript循环遍历每个用户的hive。按照您需要的方式配置您自己的概要文件。导出reg键。的所有实例HKEY_CURRENT_USER在reg文件中使用HKEY_LOCAL_MACHINE'TempHive保存.reg文件。现在运行vbscript。这么做已经很多年了。请注意,此更改适用于所有当前和未来的用户,除了当前登录的用户(reg.exe不能加载当前正在使用的hive)。如果您需要它排除某些用户,我将需要调整脚本。

On Error Resume Next
Set WshShell = WScript.CreateObject("WScript.Shell")
strWinDir = WshShell.ExpandEnvironmentStrings("%windir%")
strSystemDrive = WshShell.ExpandEnvironmentStrings("%SystemDrive%")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(strSystemDrive & "'Users")
Set colSubfolders = objFolder.Subfolders
  For Each objSubfolder in colSubfolders
    WshShell.Run(strWinDir & "'System32'cmd.exe /c " & strWinDir & "'System32'reg.exe load HKLM'TempHive " & chr(34) & "C:'Users'" & objSubfolder.Name & "'NTUser.dat" & chr(34)),0, True
    WshShell.Run(strWinDir & "'regedit.exe /i /s " & strSystemDrive & "'PostInstall'PropPref.reg"),0, True
    WshShell.Run(strWinDir & "'System32'cmd.exe /c " & strWinDir & "'System32'reg.exe unload HKLM'TempHive"),0, True
  Next
WScript.Quit