Re: creating a reg file

From: Dave Patrick (mail_at_NoSpam.DSPatrick.com)
Date: 02/19/04


Date: Wed, 18 Feb 2004 18:06:46 -0700

Try

Set objTextFileout = objFSO.CreateTextFile("d:\profiles.reg", True, True)

The file needs to be unicode.

-- 
Regards,
Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft MVP [Windows NT/2000 Operating Systems]
Microsoft Certified Professional [Windows 2000]
http://www.microsoft.com/protect
"Nick Bowden" wrote:
| I have been trying to get the script below to output the
| data it retrieves from the registry into the standard reg
| file format that can be merged with the registry later.
| Anyone able to assist? or is this not possible?
| Thanks
| Nick Bowden
|
| On Error Resume Next
|
| Const HKLM=&H80000002 'HKEY_LOCAL_MACHINE
|
| Const REG_SZ=1
| Const REG_EXPAND_SZ=2
| Const REG_BINARY=3
| Const REG_DWORD=4
| Const REG_MULTI_SZ=7
|
| strComputer = "."
|
|
|
| Set oReg=GetObject("winmgmts:
| {impersonationLevel=impersonate}!\\" & strComputer
| & "\root\default:StdRegProv")
| Set WSHShell = WScript.CreateObject("WScript.Shell")
| Set objFSO = CreateObject("Scripting.FileSystemObject")
| Set objTextFileout = objFSO.CreateTextFile
| ("d:\profiles.reg", True)
|
| objTextFileout.WriteLine("Windows Registry Editor Version
| 5.00")
| objTextFileout.WriteLine("")
|
| strKeyPath = "SOFTWARE\Microsoft\Windows
| NT\CurrentVersion\ProfileList"
| oReg.EnumKey HKLM, strKeyPath, arrSubKeys
|
| For Each subkey In arrSubKeys
| strRegKey = "HKEY_LOCAL_MACHINE\" & strKeyPath
| & "\" & subKey & "\ProfileImagePath"
| strRegKey1 = strKeyPath & "\" &
| subKey '& "\ProfileImagePath"
| strAccess = WSHShell.RegRead(strRegKey)
|   intStringLength = Len(strAccess)-InStrRev
| (strAccess, "\")
| strAccount= Right(strAccess,intStringLength)
|
| If IsNumeric(left(strAccount,7)) = true then
| objTextFileout.WriteLine("[" & strKeyPath
| & "\" & subKey & "\ProfileImagePath" & "]")
| objTextFileout.WriteLine(EnumValues(HKLM,
| strRegKey1))
| objTextFileout.WriteLine("")
| end if
| Next
|
| '*******************
| '*     Function Name:          EnumValues
| '*     Inputs:               Key, Subkey
| '*     Example           wscript.echo EnumValues
| (HKCU, "Software\Microsoft")
| '*     Returns:          List of all values in the format;
| '*                         NAME,TYPE,VALUE
| '*******************
|
| Function EnumValues(Key, SubKey)
|      Dim Ret()
|      oReg.EnumValues Key,SubKey, sKeys, iKeyType 'fill the
| array
|
|      ReDim Ret(UBound(sKeys))
|
|      For Count = 0 to UBound(sKeys)
|     'wscript.echo sKeys(count) & " " & iKeyType
|          Select Case iKeyType(Count)
|                Case REG_SZ
|                     oReg.GetStringValue Key,SubKey, sKeys
| (Count), sValue
|                     Ret(Count) = Chr(34) & sKeys(Count)&
| Chr(34) & "=" & Chr(34)& sValue &Chr(34)
|
|                Case REG_EXPAND_SZ
|                     oReg.GetExpandedStringValue
| Key,SubKey, sKeys(Count), sValue
|                     Ret(Count) =  Chr(34) & sKeys(Count)&
| Chr(34)& "=" & "hex" & ":" & sValue
|
|                Case REG_BINARY
|                     oReg.GetBinaryValue Key,SubKey, sKeys
| (Count), aValue
|                     Ret(Count) = Chr(34) & sKeys(Count)&
| Chr(34) & "=" & "REG_BINARY" & ":" & Join(aValue,"")
|
|                Case REG_DWORD
|                     oReg.GetDWORDValue Key,SubKey, sKeys
| (Count), lValue
|                     Ret(Count) =  Chr(34) & sKeys(Count)&
| Chr(34)& "=" & "DWORD" & ":" & lValue
|
|                Case REG_MULTI_SZ
|                     oReg.GetMultiStringValue Key,SubKey,
| sKeys(Count), sValue
|                     Ret(Count) =  Chr(34) & sKeys(Count)&
| Chr(34) & "=" & "REG_MULTI_SZ" & ":" & Join(sValue,"")
|
|           End Select
|      Next
|      EnumValues = Join(Ret,vbCrLf)
| End Function
| Wscript.quit(0)
|


Relevant Pages

  • Re: eventlog performance
    ... Will Windows' logging miss events under high load situations? ... Const ForWriting = 2 ... ' Event Type: Failure Audit ... FailedFileAccessCount = FailedFileAccessCount + 1 ...
    (microsoft.public.security)
  • Re: Layering (stacking?) windows with only title bars showing.
    ... windows programmatically in apps that don't offer direct support for it. ... Const csSubTitle As String = "JEMCascadeWindows" ... cascading method in a past version of word, ... one gap, ...
    (microsoft.public.mac.office.word)
  • Re: Layering (stacking?) windows with only title bars showing.
    ... windows programmatically in apps that don't offer direct support for it. ... Const csSubTitle As String = "JEMCascadeWindows" ... cascading method in a past version of word, ... didn't have any gaps in it with all my open documents, ...
    (microsoft.public.mac.office.word)
  • Re: VBScript does not run on Windows 2003
    ... Const WinHttpRequestOption_SslErrorIgnoreFlags = 4 ... Call CheckForErrors(oError, oNode, oResultFromWeb, sStatus) ... Perhaps post the script removing your company specific information ... I am testing it running on a Windows 2003 box and it is ...
    (microsoft.public.windows.server.scripting)
  • Re: Layering (stacking?) windows with only title bars showing.
    ... windows programmatically in apps that don't offer direct support for it. ... Const csSubTitle As String = "JEM Cascade Windows" ... Dim nCount As Long ... Dim nLeft As Long ...
    (microsoft.public.mac.office.word)