Quote Originally Posted by baarsd View Post
e.g.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\Software\Novell\ZCM\ZenLgn\Hist ory\CachedUserZenNames]
"NIWA\\baarsd"="NIWA\\baarsd"
"NIWA\\baker"="NIWA\\baker"

gets changed to

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\Software\Novell\ZCM\ZenLgn\Hist ory\CachedUserZenNames]
"NIWA\\baarsd"="niwa.local\\baarsd"
"NIWA\\baker"="niwa.local\\baker"

Here is the script file I used

--------------------

$file = FileOpen("C:\Temp\cacheduserzennames.reg", 0)
$write = FileOpen("C:\Temp\cachednames_fixed.reg", 2)

; Check if file opened for reading OK
If $file = -1 Then
MsgBox(0, "Error", "Unable to open file.")
Exit
EndIf

; Check if file opened for writing OK
If $write = -1 Then
MsgBox(0, "Error", "Unable to open file.")
Exit
EndIf

; Start top of cachednames_fixed.reg

FileWriteLine($write, "Windows Registry Editor Version 5.00")
FileWriteLine($write, "")
FileWriteLine($write, "[HKEY_LOCAL_MACHINE\Software\Novell\ZCM\ZenLgn\Hist ory\CachedUserZenNames]")

; Read in lines of text until the EOF is reached
While 1
$line = FileReadLine($file)
If @error = -1 Then ExitLoop
if StringRegExp($line, '"="') Then
$array = StringSplit($line,'"="',1)
$edited = StringReplace($array[2], "NIWA", "niwa.local")
FileWriteLine($write, $array[1] & '"="' & $edited)
;MsgBox(0, "Line read:", $array[1] & " and " & $edited)
EndIf

Wend

FileClose($file)
FileClose($write)
We are also to the point where we're doing this same scenario. Here is a cmd script I wrote to do the same as your Autoit script, hope it is useful to someone out there:

Code:
setlocal enabledelayedexpansion
set __REALM=YourRealmName
if not defined __REALM goto :EOF

REM query cached Zenworks user names in the registry separating registy value and data strings
for /f "usebackq tokens=1,3 skip=2" %%A in (`reg.exe query "hklm\software\novell\zcm\zenlgn\history\cacheduserzennames"`) do (

     REM separate the OldRealm and user strings from the data string
     for /f "usebackq tokens=1,2 delims=\" %%D in ('%%B') do (

          REM import cached Zenworks user names registry, replacing value's data with the NewRealm\user
          reg.exe add "hklm\software\novell\zcm\zenlgn\history\cacheduserzennames" /v "%%A" /t REG_SZ /d "%__REALM%\%%E" /f
     )

)