WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Registry
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

How to Map a Registry Key to a Hive File

Keywords: hive file Registry RegUnloadHive wntAccessAdd security 1526

Question, RE: RegUnLoadHive:

Are there any problems with RegUnloadHive? I get a 1528 error indicating an invalid subkey even though the subkey exists. I'm trying to unload the @REGMACHINE, "SOFTWARE\ORACLE" key.

Also, I need a way to dynamically import a previously exported selected branch of the registry. Thanks.

Answer:

A hive is a discrete body of keys, subkeys, and values that is rooted at the top of the registry hierarchy. It is a binary file. You can only load hives at the root of the registry. In your case, SOFTWARE\ORACLE doesn't seem to be a hive otherwise it would be rooted at the top.

To use the RegLoadHive function. Use the "Search" in the Windows Interface Language help file to find it.

Regarding your other question, dynamically importing a previously exported branch (a *.REG file, which is a text file) (as opposed to a hive which is a binary file):

Is it saved as a *.reg file? If so, you can import a branch using the following command:


RunWait("regedit.exe","/s mystuff.reg") 
By the way, to export a REG file in Windows 95/NT, you can use the following command line:

run('regedit.exe', '/e "c:\temp\myfile.reg" "HKEY_LOCAL_MACHINE\Control Panel"')
This will save the registry subkey "Control Panel" under "HKEY_LOCAL_MACHINE" in a text file called "myfile.reg" in the "C:\TEMP" directory.

Another Question, RE: RegUnLoadHive:

After installing software, I want to unload a hive to a file so that I can reload the information (hive) at a later date.

Unless I am misinterpreting RegLoadHive, RegLoadHive will allow me to restore a hive. I can't figure out how to save the hive after an install!

The syntax forRegUnloadHive, RegUnloadHive(handle, subkey) doesn't allow you to specifiy a filename.

Rather than export/import the entire registry, I thought I'd just export/import the hive.

Answer:

RegLoadHive connects a hive file into the registry.

RegUnloadHive simply disconnects the hive file from the registry.

It sounds like what you need to do is MAKE the hive file in the first place. In regedit (NT version but not in 95), on the Registry menu, there is a SAVE KEY that will make your hive file.


Question, RE: Exporting Hives:

I Need to solve a major free-seating problem in Windows 95. Not all programs under Windows 95 are using the Windows 95 registry correctly. Many programs make changes in the HLKM\Software key, when they should make it in the HKeyCurrentUser. I Made a winbatch which at logoff copies the HKLM\Software in HKeyCurrentUser\Software\MyBatch. It gets distributed with the USER.DAT over the network. At Login a copy the key back. This takes A LOT of time. (Up to 45 minutes for the COMPLETE Software key)

Is there a way to export Hives? Or a FAST routine I can use?

Answer:

For unloading hives in Windows 95, see the article:

http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/Registry+How~to~Save~Hive~Files~in~Windows~95.txt
Well we can read hives. We don't export them. 45 minutes sounds like a long time. How are you doing it?

You can send keystrokes to regedit to export hives (in NT), but I don't think that is what you want to do.

If you keep the hive file on the network server in the users directory it might just work without continual importing and exporting...


Question, RE: RegUnLoadHive and Permission Denied:

I'm trying to create a subkey in the SYSTEM Hive of a NT that is not loaded. I'm getting the 1526 error: Regload/Unload Hive: Access Denied.

Here is the code sample:


RegLoadHive (@REGMACHINE, "Temp", "D:\WINNT\SYSTEM32\CONFIG\SYSTEM" )

If !RegExistKey (@REGMACHINE, "Temp\DISK")
   KEY = RegOpenKey (@REGMACHINE, "Temp")
   RegCreateKey (KEY, "DISK")
   RegCLoseKey (KEY)
EndIf
Key1 = RegOpenKey (@REGMACHINE, "Temp\DISK" )
RegSetBin (Key1, "[Information]", Value )
RegCLoseKey (Key1)
RegUnloadHive (@REGMACHINE, "Temp")
At the RegUnloadHive command, it is there that it says "Access Denied". Even if I go in Regedt32, I cannot unload the HIve, unless I delete the new Key created. But, if I do all those steps manually with regedt32, I don't have any problems.

Answer:

I'm worried about the first statement...

RegLoadHive (@REGMACHINE, "Temp", "D:\WINNT\SYSTEM32\CONFIG\SYSTEM" )
is:

D:\WINNT\SYSTEM32\CONFIG\SYSTEM
*really* the name of a hive file ???

If yes, I would then check the security permissions carefully. Perhaps they are not getting inherited properly.

The wntAccessAdd functions in the NT network extender can modify security settings. Maybe regedit is automatically setting some permissions that regLoadHive is not.


Article ID:   W13733
Filename:   RegLoadHive - RegUnloadHive - and Running REG Files.txt
File Created: 2017:08:29:11:58:52
Last Updated: 2017:08:29:11:58:52