Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

vbscript to read registry keys and its subkeys

$
0
0

Hello All,

I want to change the Source file Server path location in the reg path HKEY_CLASSES_ROOT\Installer\Products\Product GUID\SourceList\Net\1 of every client machines, as we have removed the existing Application server with a new one...We were able to change the old server path to new server path using the "replace" function in vbscript.

On error resume next 
Const HKEY_CLASS_ROOT = &H80000000 

strComputer = "." 
strKeyPath = "Installer\Products" 

Set objShell = CreateObject("WScript.Shell") 
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_ 
strComputer & "\root\default:StdRegProv") 

oReg.EnumKey HKEY_CLASS_ROOT, strKeyPath, arrSubkeys 

If IsArray(arrSubkeys) Then 
For Each strSubkey In arrSubkeys 

strkeyvalue = objShell.regread ("HKEY_CLASSES_ROOT\Installer\Products\" & strSubkey & "\SourceList\Net\1") 

strKeySuffix = Left(strkeyvalue, 12) 

if strKeySuffix = "\\DCASRV11" then 

newstrKeyValue = Replace (strkeyvalue, "\\DCASRV11", "\\DCASRV12") 

newstrKeyValue2 = Replace (newstrKeyValue ,"SMSPKGC$" ,"SMSPKGP$") 



strKeyPath = "Installer\Products\" & strSubkey & "\SourceList\Net\" 
strValueName = "1" 
strValue = newstrKeyValue2 

oReg.SetExpandedStringValue HKEY_CLASSES_ROOT,strKeyPath,strValueName,strValue 


End if 
Next 
End If 

 

But the probelm is it is not overwriting the existing value. If I run the vbs after removing the array part(tried with one GUID) it is overwriting the Value..

I think the issue is with the "oReg.SetExpandedStringValue HKEY_CLASSES_ROOT,strKeyPath,strValueName,strValue"



Any thoughts on this..

 

regards

Anphi


Thanks and regards Aneesh Philip

Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>