Jump to content

Exporting Registry Keys through script


Recommended Posts

Ok,

trying to find an easier way to do this,

i want to export a whole subset of registry keys.

particulary [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Printers]

but all i can find through vb or wmi is how to read one key at a time, which is alot of keys with multiple types of keys. any ideas on a good way to accomplish this?

Link to comment
Share on other sites


This will export the file "Exported.reg" to your C drive, it is the

correct registry path for what you want exported...

REGEDIT /E C:/Exported.reg "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Printers"

Simply put it in a .BAT or .CMD file and run from anywhere.

REGEDIT - runs regedit.exe

/E - Tells it to "export".

C:/Exported.reg - Name of your registry file that will be exported

"HKLM/../../../../.." - Registry key to be exported.

Edited by LeveL
Link to comment
Share on other sites

You can use either regedit, as already suggested or if installed reg.exe.

The latter would definitely be better if ran from a vbscript, so here are both examples using that scripting method

REGEDIT

sBackupFile = "X:\KeyBkUp.reg"
sRegPath = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Printers"
sCmd = "REGEDIT /E """ & sBackupFile & """ " & """" & sRegPath & """"
Set oShell = CreateObject("WScript.Shell")
oShell.Run sCmd, 0, True

REG.EXE

sBackupFile = "X:\KeyBkUp.reg"
sRegPath = "HKLM\SYSTEM\CurrentControlSet\Control\Print\Printers"
sCmd = "%COMSPEC% /C REG EXPORT """ & sRegPath & """ " & """" &_
sBackupFile & """"
Set oShell = CreateObject("WScript.Shell")
oShell.Run sCmd, 0, True

<Edit>

BTW LeveL it should be

REGEDIT /E C:\Exported.reg

not

REGEDIT /E C:/Exported.reg

</Edit>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...