Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows 打开其他用户注册表设置_Windows_Registry - Fatal编程技术网

Windows 打开其他用户注册表设置

Windows 打开其他用户注册表设置,windows,registry,Windows,Registry,我想编写一个应用程序,向本地计算机上的所有用户写入一个指定的密钥(例如:我想为所有用户将IE收藏夹的位置设置为同一个文件夹) PS 有人用过这些函数吗? LoadUserProfile RegOpenCurrentUser CreateProcessAsUser前几天我们遇到了完全相同的问题 我们发现,您只需打开HKEY_USERShive并将更改写入每个用户的SID即可 而且,如果您希望为任何新用户显示设置,还应将这些设置应用于HKEY\u users/.DEFAULT键 也就是说,只需将您的

我想编写一个应用程序,向本地计算机上的所有用户写入一个指定的密钥(例如:我想为所有用户将IE收藏夹的位置设置为同一个文件夹)

PS 有人用过这些函数吗? LoadUserProfile RegOpenCurrentUser
CreateProcessAsUser

前几天我们遇到了完全相同的问题

我们发现,您只需打开
HKEY_USERS
hive并将更改写入每个用户的SID即可

而且,如果您希望为任何新用户显示设置,还应将这些设置应用于
HKEY\u users/.DEFAULT

也就是说,只需将您的设置写入

HKEY_USERS\S-1-5-XX-XXXXXXXX-XXXXXXXXX-XXXXXXXX-XXXX\Software\...
对于每个现有的小岛屿发展中国家,以及:

HKEY_USERS\.DEFAULT\Software\...

我已经做过很多次了。其想法是更新当前登录用户的HKCU(这很容易)。然后,您必须枚举系统上的每个配置文件,并找到它们的ntuser.dat文件(这也很简单)

找到ntuser.dat文件后,将其加载到HKLM配置单元中的临时密钥中(我通常使用“HKLM\TempHive”。然后进行编辑

如果有超过1个用户登录,他们的配置文件将根据其SID加载到HKEY_用户下。只需更新该位置

要修改任何新用户的设置,只需在HKEY_users.DEFAULT下修改相应的键,或使用下面的Delphi代码,通过加载默认用户的HKCU注册表配置单元(存储在ntuser.dat中)即可完成此操作

更新:我找到了演示如何更新未登录系统的HKCU用户群的Delphi代码

这需要Russell Libby的“特权”组件

不久前,我还编写了一个VBScript来完成此任务。我使用它来修改一些Internet Explorer设置,但您可以根据需要自定义它。它还演示了一般过程:

Option Explicit

Dim fso
Dim WshShell
Dim objShell
Dim RegRoot
Dim strRegPathParent01
Dim strRegPathParent02

Set fso = CreateObject("Scripting.FileSystemObject")
Set WshShell = CreateObject("WScript.shell")


'==============================================
' Change variables here
'==============================================
'
'This is where our HKCU is temporarily loaded, and where we need to write to it
RegRoot = "HKLM\TEMPHIVE"
'
strRegPathParent01 = "Software\Microsoft\Windows\CurrentVersion\Internet Settings" 
strRegPathParent02 = "Software\Microsoft\Internet Explorer\Main"
'
'======================================================================



Call ChangeRegKeys()  'Sets registry keys per user

Sub ChangeRegKeys
 'Option Explicit
 On Error Resume Next

 Const USERPROFILE = 40
 Const APPDATA = 26

 Dim iResult
 Dim iResult1
 Dim iResult2
 Dim objShell
 Dim strUserProfile
 Dim objUserProfile
 Dim strAppDataFolder
 Dim strAppData
 Dim objDocsAndSettings
 Dim objUser
 Set objShell = CreateObject("Shell.Application")
 Dim sCurrentUser

 sCurrentUser = WshShell.ExpandEnvironmentStrings("%USERNAME%")

 strUserProfile = objShell.Namespace(USERPROFILE).self.path
 Set objUserProfile = fso.GetFolder(strUserProfile)
 Set objDocsAndSettings = fso.GetFolder(objUserProfile.ParentFolder)

 'Update settings for the user running the script
 '(0 = default, 1 = disable password cache)
 WshShell.RegWrite "HKCU\" & strRegPathParent01 & "\DisablePasswordCaching", "00000001", "REG_DWORD"
 WshShell.RegWrite "HKCU\" & strRegPathParent02 & "\FormSuggest PW Ask", "no", "REG_SZ"


 strAppDataFolder = objShell.Namespace(APPDATA).self.path
 strAppData = fso.GetFolder(strAppDataFolder).Name

 ' Enumerate subfolders of documents and settings folder
 For Each objUser In objDocsAndSettings.SubFolders 
  ' Check if application data folder exists in user subfolder
  If fso.FolderExists(objUser.Path & "\" & strAppData) Then 
   'WScript.Echo "AppData found for user " & objUser.Name
   If ((objUser.Name <> "All Users") and _
    (objUser.Name <> sCurrentUser) and _
    (objUser.Name <> "LocalService") and _ 
    (objUser.Name <> "NetworkService")) then
    'Load user's HKCU into temp area under HKLM
    iResult1 = WshShell.Run("reg.exe load " & RegRoot & " " & chr(34) & objDocsAndSettings & "\" & objUser.Name & "\NTUSER.DAT" & chr(34), 0, True)
    If iResult1 <> 0 Then
     WScript.Echo("***   An error occurred while loading HKCU: " & objUser.Name)
    Else
     WScript.Echo("HKCU loaded: " & objUser.Name)
    End If

    WshShell.RegWrite RegRoot & "\" & strRegPathParent01 & "\DisablePasswordCaching", "00000001", "REG_DWORD"
    WshShell.RegWrite RegRoot & "\" & strRegPathParent02 & "\FormSuggest PW Ask", "no", "REG_SZ"

    iResult2 = WshShell.Run("reg.exe unload " & RegRoot,0, True) 'Unload HKCU from HKLM
    If iResult2 <> 0 Then
     WScript.Echo("*** An error occurred while unloading HKCU: " & objUser.Name & vbcrlf)
    Else
     WScript.Echo("   unloaded: " & objUser.Name & vbcrlf)
    End If
   End If

  Else
   'WScript.Echo "No AppData found for user " & objUser.Name
  End If
 Next

End Sub
选项显式
模糊fso
昏暗的地狱
昏暗的奥布舍尔
模糊再根
Dim STREGPATHPARENT01
Dim STREGPATHPARENT02
设置fso=CreateObject(“Scripting.FileSystemObject”)
设置WshShell=CreateObject(“WScript.shell”)
'==============================================
'在此处更改变量
'==============================================
'
“这是我们的HKCU临时加载的地方,也是我们需要写入的地方
RegRoot=“HKLM\TEMPHIVE”
'
strRegPathParent01=“软件\Microsoft\Windows\CurrentVersion\Internet设置”
strRegPathParent02=“软件\Microsoft\Internet Explorer\Main”
'
'======================================================================
Call ChangeRegKeys()'为每个用户设置注册表项
子更改注册表项
'选项显式
出错时继续下一步
Const USERPROFILE=40
常数APPDATA=26
暗淡的结果
Dim iResult1
Dim iResult2
昏暗的奥布舍尔
暗结构轮廓
模糊对象轮廓
Dim数据文件夹
暗带数据
Dim objDocsAndSettings
暗色objUser
设置objShell=CreateObject(“Shell.Application”)
暗流用户
sCurrentUser=WshShell.ExpandEnvironmentStrings(“%USERNAME%”)
strUserProfile=objShell.Namespace(USERPROFILE.self.path)
设置objUserProfile=fso.GetFolder(strUserProfile)
设置objDocsAndSettings=fso.GetFolder(objUserProfile.ParentFolder)
'更新运行脚本的用户的设置
'(0=默认值,1=禁用密码缓存)
WshShell.RegWrite“HKCU\”和strRegPathParent01&“DisablePasswordCaching”、“00000001”、“REG\u DWORD”
WshShell.RegWrite“HKCU\”和stregpathparent02&“FormSuggest PW Ask”、“no”、“REG_SZ”
StrapDataFolder=objShell.Namespace(APPDATA.self.path)
StrapData=fso.GetFolder(StrapDataFolder).Name
'枚举文档和设置文件夹的子文件夹
对于objDocsAndSettings.SubFolders中的每个objUser
'检查用户子文件夹中是否存在应用程序数据文件夹
如果存在fso.folder(objUser.Path&“\”&StrapData),则
'WScript.Echo“为用户找到AppData”&objUser.Name
如果((objUser.Name“所有用户”)和_
(objUser.Name sCurrentUser)和_
(objUser.Name“LocalService”)和
(objUser.Name“NetworkService”))然后
'将用户的HKCU加载到HKLM下的临时区域
iResult1=WshShell.Run(“reg.exe加载”和“重新启动”&&chr(34)&objDocsAndSettings&“\”和objUser.Name&“\NTUSER.DAT”&chr(34),0,True)
如果iResult1为0,则
WScript.Echo(“***加载HKCU时出错:”&objUser.Name)
其他的
Echo(“HKCU加载:”&objUser.Name)
如果结束
WshShell.RegWrite重新根目录&“\”&stregpathparent01&“\DisablePasswordCaching”、“00000001”、“REG\u DWORD”
WshShell.RegWrite重新根目录&“\”&stregpathparent02&“\FormSuggest PW Ask”、“no”、“regu SZ”
iResult2=WshShell.Run(“reg.exe unload”&重新启动,0,True)”从HKLM卸载HKCU
如果iResult2 0那么
WScript.Echo(“***卸载HKCU时出错:”&objUser.Name&vbcrlf)
其他的
Echo(“已卸载:”&objUser.Name&vbcrlf)
如果结束
如果结束
其他的
'WScript.Echo“找不到用户的AppData”&objUser.Name
如果结束
下一个
端接头

为什么希望所有用户共享同一文件夹?如果用户最终覆盖了彼此的收藏夹,这会让很多用户感到烦恼。同意-不要更改位置。改用通用收藏夹:所有用户的收藏夹:C:\Documents and Settings\all users\favorites特定用户的收藏夹:C:\Documents and Settings\\FaVoritesys,Remus,人们已经使用了这些功能。请只问你真正想问的问题。像这样的是/否问题是没有用的。1.这只是一个测试,试图将所有用户的收藏夹位置修改到同一个文件夹2.我不知道如何使用LoadUserProfile,因为我不是程序员,我只是喜欢我自己也在学习,我写的程序是供我个人使用的(或免费的),我不想得到帮助和赚钱……所以我不知道如何使用windows操作系统提供的所有功能,只有当前登录用户的SID才会出现。如果用户没有登录,那么操作系统就不允许
Option Explicit

Dim fso
Dim WshShell
Dim objShell
Dim RegRoot
Dim strRegPathParent01
Dim strRegPathParent02

Set fso = CreateObject("Scripting.FileSystemObject")
Set WshShell = CreateObject("WScript.shell")


'==============================================
' Change variables here
'==============================================
'
'This is where our HKCU is temporarily loaded, and where we need to write to it
RegRoot = "HKLM\TEMPHIVE"
'
strRegPathParent01 = "Software\Microsoft\Windows\CurrentVersion\Internet Settings" 
strRegPathParent02 = "Software\Microsoft\Internet Explorer\Main"
'
'======================================================================



Call ChangeRegKeys()  'Sets registry keys per user

Sub ChangeRegKeys
 'Option Explicit
 On Error Resume Next

 Const USERPROFILE = 40
 Const APPDATA = 26

 Dim iResult
 Dim iResult1
 Dim iResult2
 Dim objShell
 Dim strUserProfile
 Dim objUserProfile
 Dim strAppDataFolder
 Dim strAppData
 Dim objDocsAndSettings
 Dim objUser
 Set objShell = CreateObject("Shell.Application")
 Dim sCurrentUser

 sCurrentUser = WshShell.ExpandEnvironmentStrings("%USERNAME%")

 strUserProfile = objShell.Namespace(USERPROFILE).self.path
 Set objUserProfile = fso.GetFolder(strUserProfile)
 Set objDocsAndSettings = fso.GetFolder(objUserProfile.ParentFolder)

 'Update settings for the user running the script
 '(0 = default, 1 = disable password cache)
 WshShell.RegWrite "HKCU\" & strRegPathParent01 & "\DisablePasswordCaching", "00000001", "REG_DWORD"
 WshShell.RegWrite "HKCU\" & strRegPathParent02 & "\FormSuggest PW Ask", "no", "REG_SZ"


 strAppDataFolder = objShell.Namespace(APPDATA).self.path
 strAppData = fso.GetFolder(strAppDataFolder).Name

 ' Enumerate subfolders of documents and settings folder
 For Each objUser In objDocsAndSettings.SubFolders 
  ' Check if application data folder exists in user subfolder
  If fso.FolderExists(objUser.Path & "\" & strAppData) Then 
   'WScript.Echo "AppData found for user " & objUser.Name
   If ((objUser.Name <> "All Users") and _
    (objUser.Name <> sCurrentUser) and _
    (objUser.Name <> "LocalService") and _ 
    (objUser.Name <> "NetworkService")) then
    'Load user's HKCU into temp area under HKLM
    iResult1 = WshShell.Run("reg.exe load " & RegRoot & " " & chr(34) & objDocsAndSettings & "\" & objUser.Name & "\NTUSER.DAT" & chr(34), 0, True)
    If iResult1 <> 0 Then
     WScript.Echo("***   An error occurred while loading HKCU: " & objUser.Name)
    Else
     WScript.Echo("HKCU loaded: " & objUser.Name)
    End If

    WshShell.RegWrite RegRoot & "\" & strRegPathParent01 & "\DisablePasswordCaching", "00000001", "REG_DWORD"
    WshShell.RegWrite RegRoot & "\" & strRegPathParent02 & "\FormSuggest PW Ask", "no", "REG_SZ"

    iResult2 = WshShell.Run("reg.exe unload " & RegRoot,0, True) 'Unload HKCU from HKLM
    If iResult2 <> 0 Then
     WScript.Echo("*** An error occurred while unloading HKCU: " & objUser.Name & vbcrlf)
    Else
     WScript.Echo("   unloaded: " & objUser.Name & vbcrlf)
    End If
   End If

  Else
   'WScript.Echo "No AppData found for user " & objUser.Name
  End If
 Next

End Sub