I was working on a VbScript to iterate through registry keys and reading a registry key of type “Reg_Expand_SZ“ which mostly contains Expandable Environment variables. I used WMI method 'GetExpandedStringValue()' to read it but it always expands %Variables% to their values. For instance, if key value contains %userprofile%, it would be expanded to Local User Profile Folder. And this was not my requirement. My need was to read the Value as it is with all %Variables% without expanding them. I even used WMI method 'GetStringValue()' but same result happened. I found a simple solution for this. I kept using WMI to iterate through registry keys, and when I found my required registry key path, instead of using 'GetExpandedStringValue()' or 'GetStringValue()' I used Windows Scripting Host method RegRead() method, which reads the key value without expanding its %Variables% to their values.
VbScript: ReadRead Method.
- Dim WsShell
- Set WsShell=CreateObject("Wscript.Shell")
- sAcadUnNamedProfileACAD=WsShell.RegRead ("HKCU\" & SelecteAcadReg & "\Profiles\<<Unnamed Profile>>\General\\ACAD")
No comments:
Post a Comment