Re: creating a reg file
From: Dave Patrick (mail_at_NoSpam.DSPatrick.com)
Date: 02/19/04
- Next message: terry: "Help!!!"
- Previous message: Nick Bowden: "creating a reg file"
- In reply to: Nick Bowden: "creating a reg file"
- Next in thread: Nick Bowden: "Re: creating a reg file"
- Reply: Nick Bowden: "Re: creating a reg file"
- Messages sorted by: [ date ] [ thread ]
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) |
- Next message: terry: "Help!!!"
- Previous message: Nick Bowden: "creating a reg file"
- In reply to: Nick Bowden: "creating a reg file"
- Next in thread: Nick Bowden: "Re: creating a reg file"
- Reply: Nick Bowden: "Re: creating a reg file"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|