Компьютерный форум OSzone.net  

Компьютерный форум OSzone.net (http://forum.oszone.net/index.php)
-   Программное обеспечение Windows (http://forum.oszone.net/forumdisplay.php?f=7)
-   -   Как одним BAT/CMD отредактировать разную у всех веткку HKU\S-1-5-21-........ (http://forum.oszone.net/showthread.php?t=216531)

Valek271183 26-09-2011 22:47 1760707

Как одним BAT/CMD отредактировать разную у всех веткку HKU\S-1-5-21-........
 
Точнее как мне запустить с Skype в "режиме совместимости с Vista" командной строкой или bat файлом в ветке HKEY_USERS\S-1-5-21-3909451403-3134265930-2030886782-1000\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers
Ведь название ветки \S-1-5-21-3909451403-3134265930-2030886782-1000\ у всех разные, как мне одной командой редактировать эту ветку на разных компьютерах

a_a 27-09-2011 11:48 1760936

Так а что мешает получить этот SID программно?
К примеру по аналогии с вот таким кодом:
Код:

On Error Resume Next
Const HKEY_USERS          = &H80000003
strComputer = "." 
Set objRegistry=GetObject("winmgmts:\\" & _      strComputer & "\root\default:StdRegProv") 
strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList"
objRegistry.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubkeys 
For Each objSubkey In arrSubkeys    strValueName = "ProfileImagePath"   
strSubPath = strKeyPath & "\" & objSubkey   
objRegistry.GetExpandedStringValue HKEY_USERS E,strSubPath,strValueName,strValue       
if fullpath = strValue Then       
sid = objSubkey       
end if Nex

Здесь мы получаем SID текущего пользователя для конкретной ветки.
Дальше добавляешь SID в начало пути и на каждом компьютере скайп запускаться будет так как надо.

Valek271183 27-09-2011 12:00 1760942

Если можно на конкретном примере привести, мне не очень понятно как это всё будет выглядеть

a_a 27-09-2011 12:15 1760949

Код:

trusted&local intranet sites********************************"
TextStream.WriteLine " "

On Error Resume Next

Const HKEY_LOCAL_MACHINE = &H80000002

strComputer = "."
 
Set objRegistry=GetObject("winmgmts:\\" & _
    strComputer & "\root\default:StdRegProv")
 
strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList"
objRegistry.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubkeys
 
For Each objSubkey In arrSubkeys
    strValueName = "ProfileImagePath"
    strSubPath = strKeyPath & "\" & objSubkey
    objRegistry.GetExpandedStringValue HKEY_LOCAL_MACHINE,strSubPath,strValueName,strValue
        if fullpath = strValue Then
        sid = objSubkey
        end if
Next


' Constants (taken from WinReg.h)
'
Const HKEY_CLASSES_ROOT  = &H80000000
Const HKEY_CURRENT_USER  = &H80000001

Const HKEY_USERS          = &H80000003

Const REG_SZ        = 1
Const REG_EXPAND_SZ = 2
Const REG_BINARY    = 3
Const REG_DWORD    = 4
Const REG_MULTI_SZ  = 7

' Chose computer name, registry tree and key path
'
strComputer = "." ' Use . for current machine
hDefKey = HKEY_USERS
strKeyPath = sid+"\software\policies\microsoft\windows\currentversion\internet settings\zonemapKey"




' Connect to registry provider on target machine with current user
'
Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")

' Enum the subkeys of the key path we've chosen
'
oReg.EnumKey hDefKey, strKeyPath, arrSubKeys

For Each strSubkey In arrSubKeys

  ' Show the subkey
  '


  ' Show its value names and types
  '
  strSubKeyPath = strKeyPath & "\" & strSubkey
  oReg.EnumValues hDefKey, strSubKeyPath, arrValueNames, arrTypes

  For i = LBound(arrValueNames) To UBound(arrValueNames)
    strValueName = arrValueNames(i)
    Select Case arrTypes(i)

      ' Show a REG_SZ value
      '
      Case REG_SZ         
        oReg.GetStringValue hDefKey, strSubKeyPath, strValueName, strValue
               
        if strValue=1 then
          TextStream.WriteLine "  " & strValueName & " local site"
        end if
      if strValue=2 then
          TextStream.WriteLine "  " & strValueName & " trusted site"
        end if

     
      ' Show a REG_DWORD value
      '
      Case REG_DWORD
        oReg.GetDWORDValue hDefKey, strSubKeyPath, strValueName, uValue
               
        if uValue=1 then

          TextStream.WriteLine Mid(strSubKeyPath,2+Len(strKeyPath),Len(strSubKeyPath)) + " is a local site"
        end if
      if uValue=2 then
          TextStream.WriteLine Mid(strSubKeyPath,2+Len(strKeyPath),Len(strSubKeyPath)) + " is a trusted site"
        end if
                                 

     
    End Select
  Next

Next

Вот конкретный пример. Здесь для current user определяется SID (тот что начинается с S-1-5-21) и SID добавляется в корень пути для определения текущих настроек браузера. В твоем случае нужно выполнить будет не операцию чтения (wshell.RegRead к примеру) а операцию записи значения.

Valek271183 27-09-2011 15:51 1761112

Может я что-то недопонял или не так выразился: а как мне из .BAT и только из .BAT найти этот раздел и отредактировать его, как я понимаю имя этого раздела (S-1-5-21-....) нельзя заменить переменной, но с помощью .BAT можно вытащить его имя из ntuser.dat или из реестра или откудато ещё, и как-нибудь использовать на замену переменной

Iska 27-09-2011 17:00 1761179

Valek271183, опишите почему «из .BAT и только из .BAT», а также в какой момент, откуда и как Вы планируете его запускать.

Valek271183 27-09-2011 17:09 1761187

Спасибо большое за помощь и извините за беспокойство, нашёл другой способ. Ветка HKEY_USERS дублируется с HKEY_CURRENT_USER и всё что в ней меняется - меняется и там


Время: 18:12.

Время: 18:12.
© OSzone.net 2001-