You can just mount it to a temporary location such as:

 Code:
$intSelect = LoadHive("HKEY_USERS\Temp","\\path\to\desired\ntuser.dat")
If $intSelect = 0
   ; Get printer info.
   $strDefP = ReadValue("HKEY_USERS\Temp\Software\Microsoft\Windows NT\CurrentVersion\Windows", "Device")
   $strDefP = Substr($strDefP,1,Instr($strDefP,",")-1)
   $intErr = WriteProfileString($strFile,"Printers","Default",$strDefP)
   $intSelect = 0
   $intIndex2 = 0
   $strKey = EnumKey("HKEY_USERS\Temp\Printers\Connections", $intSelect)
   While @Error = 0
      ReDim Preserve $arrMap[1,$intIndex2]
      $temp = Split($strKey,","4)
      $arrMap[0, $intIndex2] = $temp[2]
      $arrMap[1, $intIndex2] = $temp[3]
      $intErr = WriteProfileString($strFile,"Printers",$arrMap[0, $intIndex2],$arrMap[1, $intIndex2])
      $intIndex2 = $intIndex2 + 1
      $intSelect = $intSelect + 1
      $strKey = EnumKey("HKEY_USERS\Temp\Printers\Connections", $intSelect)
   Loop
   $intSelect = UnLoadHive("HKEY_USERS\Temp")
   If $intSelect <> 0
      ? "Open regedit and check HKEY_USERS\Temp.  It was not unloaded."
   EndIf
Else
   ? "Could not load the hive, ..."
EndIf


Note that it probably won't work if it is in use. I think you can make a copy first and then load it.

I just saw that you were trying to retrieve printer info. I wrote a script to do that (among other things). I've added that in here. I had to re-type. So, I hope I didn't make any typos! \:\)

Regards,

Brad V


Edited by BradV (2008-05-09 02:27 PM)