在注册表的GUID中设置-自动 [英] Setting within GUID of Registry - Automated

查看:191
本文介绍了在注册表的GUID中设置-自动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我离程序员很远.但是,我正在尝试使Paperport 11自动化,以更改其扫描文档将进入的默认路径.在HKEY_USERS中是一个GUID,并且其中有注册表更改.对于每个用户而言,这都是不同的,那么我如何能够将注册表项导入此目录并使用GUID补偿更改?


[HKEY_USERS \ S-1-5-21-3036698917-4077224916-1865345272-18111 \ Software \ ScanSoft \ PaperPort桌面组\ Desktops \ Desktop1]
"Path" ="c:\\ temp"
"SimpleSearch" = dword:00000001
名称" ="
"StandardDesktop" = dword:00000000

路径说c:\\ temp就是我在注册表中更改为我想要的路径.

I am far far from a programmer. However, I am trying to automate paperport 11 to change its default path where scanned documents will go. within HKEY_USERS is a GUID and registry change is within there. This is different for every user, so how would I be able to import a registry key into this directory and compensate for the change with the GUID?


[HKEY_USERS\S-1-5-21-3036698917-4077224916-1865345272-18111\Software\ScanSoft\PaperPort Desktop Group\Desktops\Desktop1]
"Path"="c:\\temp"
"SimpleSearch"=dword:00000001
"Name"=""
"StandardDesktop"=dword:00000000

Where the path says c:\\temp is what I have changed in the registry to the path that I want it to be.

推荐答案

首先,那个SID(安全标识符),而不是GUID.

您的代码必须进行更新以枚举HKEY_USERS配置单元下的键.该枚举将返回每个键的名称,使您可以构建一个字符串,该字符串表示所需的注册表项的路径.

但是您的代码有问题.并非在所有情况下都有效.如果不是每个用户注册表配置单元都未登录到该工作站,则会在HKEY_USERS下显示.

您的代码需要管理员权限才能枚举HKEY_USERS下的所有键.您可能还没有检查实际用户的SID.您可能不希望将此路径放在本地系统"帐户或任何其他与用户无关的目录下.

您的代码只会对已经登录的用户帐户进行更改.计算机上的任何新用户都不会获得此更改.话虽如此:

您必须确保此更改最终出现在默认用户"(HKEY_USERS \ .DEFAULT)配置文件中,因为任何登录到计算机的新用户都将从默认用户"配置文件继承其初始注册表设置.

对此的更好解决方案是策略或更改登录脚本,以便每个用户都可以运行此脚本,并且它将以用户身份而不是以管理员身份执行.
First, that''s a SID (Security Identifier), not a GUID.

You''re code would have to be updated to enumerate the keys under the HKEY_USERS hive. That enumeration would return the names of each key, allowing you to build a string that represent the path to the registry key you want.

There''s a problem with your code though. It won''t work in all all situations. Not every users registry hive will show up under HKEY_USERS if they are not logged in on that workstation.

Your code requires administrator rights in order to enumerate all of the keys under HKEY_USERS. You''re also probably not checking for SIDs that are actual users. You probably don''t want to be putting this path under the Local System account, or anything else non-user related.

Your code will only make the change on user accounts that have already logged in. Any new users on the machine will not get this change. Having said that:

You have to make sure this change ends up in the Default User (HKEY_USERS\.DEFAULT) profile since any new users logging into the machine will inherit their initial registry settings from the Default User profile.

A better solution to this would have been policies or making the change in a login script so that each user can run this script and it would execute as the user, not as an administrator.


您需要的值是用户SID.此WScript将获取指定用户的SID:
The value you need is the user SID. This WScript will get the SID for a specified user:
strComputer = "."
strUsername = "username"
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objAccount = objWMIService.Get _
    ("Win32_UserAccount.Name='" & strUsername & "',Domain='atl-ws-01'")
Wscript.Echo objAccount.SID



获取用户名:



To get the username:

Set wshNetwork = CreateObject("WScript.Network")  
strUser = wshNetwork.Username  



祝你好运!



good luck!


这篇关于在注册表的GUID中设置-自动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆