Replace %userprofile% windows variable in a string with the actual path in vbscript
Posted on 2006-05-04
I have a script that reads a path from the registry and sets it as a variable and then later moves the files from that location to a mapped drive. On most computers this works fine, however on a few machines the path is set to %userprofile% instead of c:\documents and settings\user. What I want to do is look at the strprog string and if it has %userprofile% replace the %userprofile% with the string in the strUserProfile variable.
Here is the code I have.
strUserProfile = oShell.ExpandEnvironmentStrings("%USERPROFILE%")
strIdentity = WshShell.RegRead("HKCU\Identities\Default User ID")
strprog = wshshell.regread("HKCU\identities\"& stridentity & "\software\application\I want to Read").
the strprog is what would contain the %userprofile%
Thanks In Advance.