OPatiny
asked on
Exporting Registry key via VBS
Hi everybody,
I'm trying to use a VBS code found of this forum and adapt it for my need, but i'm totally lost.
I'm trying to export 3 registry entries to a file, but it's not working, because the registry entries contains space, and i really don't know how to solve this, and hope that someone could hear my pray :)
Here's my current code :
'===================
Set objShell = CreateObject("WScript.Shel l")
Set objFSO = CreateObject("Scripting.Fi leSystemOb ject")
arrRegPaths = Array( _
"HKEY_LOCAL_MACHINE\SOFTWA RE\Microso ft\Interne t Explorer\ActiveX Compatibility\{F0E42D50-36 8C-11D0-AD 81-00A0C90 DC8D9}",_
"HKEY_LOCAL_MACHINE\SOFTWA RE\Microso ft\Interne t Explorer\ActiveX Compatibility\{F0E42D60-36 8C-11D0-AD 81-00A0C90 DC8D9}",_
"HKEY_LOCAL_MACHINE\SOFTWA RE\Microso ft\Interne t Explorer\ActiveX Compatibility\{F2175210-36 8C-11D0-AD 81-00A0C90 DC8D9}" _
)
Const intForReading = 1
Const intUnicode = -1
strFileName = objShell.ExpandEnvironment Strings("% UserProfil e%") & "\Desktop\RegKeys.reg"
Set objRegFile = objFSO.CreateTextFile(strF ileName, True, True)
objRegFile.WriteLine "Windows Registry Editor Version 5.00"
For Each strRegPath In arrRegPaths
strCommand = "cmd /c REG EXPORT " & strRegPath & " " & Replace(strRegPath, "\", "_") & ".reg"
objShell.Run strCommand, 0, True
If objFSO.FileExists(Replace( strRegPath , "\", "_") & ".reg") = True Then
'WScript.Sleep 10000 ' Wait one second to give the file time to close
Set objInputFile = objFSO.OpenTextFile(Replac e(strRegPa th, "\", "_") & ".reg", intForReading, False, intUnicode)
If Not objInputFile.AtEndOfStream Then
objInputFile.SkipLine
objRegFile.Write objInputFile.ReadAll
End If
objInputFile.Close
Set objInputFile = Nothing
objFSO.DeleteFile Replace(strRegPath, "\", "_") & ".reg", True
End If
Next
objRegFile.Close
Set objRegFile = Nothing
MsgBox "Finished."
'===================
On array values, if i set it to HKEY_LOCAL_MACHINE\SOFTWAR E\Microsof t\ it's working, but it seems to don't accept space.
Many thanks in advance for your help.
I'm trying to use a VBS code found of this forum and adapt it for my need, but i'm totally lost.
I'm trying to export 3 registry entries to a file, but it's not working, because the registry entries contains space, and i really don't know how to solve this, and hope that someone could hear my pray :)
Here's my current code :
'===================
Set objShell = CreateObject("WScript.Shel
Set objFSO = CreateObject("Scripting.Fi
arrRegPaths = Array( _
"HKEY_LOCAL_MACHINE\SOFTWA
"HKEY_LOCAL_MACHINE\SOFTWA
"HKEY_LOCAL_MACHINE\SOFTWA
)
Const intForReading = 1
Const intUnicode = -1
strFileName = objShell.ExpandEnvironment
Set objRegFile = objFSO.CreateTextFile(strF
objRegFile.WriteLine "Windows Registry Editor Version 5.00"
For Each strRegPath In arrRegPaths
strCommand = "cmd /c REG EXPORT " & strRegPath & " " & Replace(strRegPath, "\", "_") & ".reg"
objShell.Run strCommand, 0, True
If objFSO.FileExists(Replace(
'WScript.Sleep 10000 ' Wait one second to give the file time to close
Set objInputFile = objFSO.OpenTextFile(Replac
If Not objInputFile.AtEndOfStream
objInputFile.SkipLine
objRegFile.Write objInputFile.ReadAll
End If
objInputFile.Close
Set objInputFile = Nothing
objFSO.DeleteFile Replace(strRegPath, "\", "_") & ".reg", True
End If
Next
objRegFile.Close
Set objRegFile = Nothing
MsgBox "Finished."
'===================
On array values, if i set it to HKEY_LOCAL_MACHINE\SOFTWAR
Many thanks in advance for your help.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
No problem. Thanks for the grade.
Regards,
Rob.
Regards,
Rob.
ASKER