parse string with VBScript
-
When I use the function SpecialFolders(Desktop), the path I back is C:\Documents and Settings\All Users\Desktop. Is there a way for me to parse this string and get only the portion "C:\Documents and Settings\All Users\" so that I can concatenate something else to it instead of "Desktop"? Thanks.
-
When I use the function SpecialFolders(Desktop), the path I back is C:\Documents and Settings\All Users\Desktop. Is there a way for me to parse this string and get only the portion "C:\Documents and Settings\All Users\" so that I can concatenate something else to it instead of "Desktop"? Thanks.
You can always use the Left function to get the first part of the string if you want to be messy. VB6 Example: strTemp = SpecialFolders(Desktop) path = Left(strTemp, Len(strTemp - 7) VB.NET Example: strTemp = SpecialFolders(Desktop) path = strTmp.Substring(0, strTmp.Length - 7)
-
When I use the function SpecialFolders(Desktop), the path I back is C:\Documents and Settings\All Users\Desktop. Is there a way for me to parse this string and get only the portion "C:\Documents and Settings\All Users\" so that I can concatenate something else to it instead of "Desktop"? Thanks.
You don't need to do that. All you need is the value of the USERPROFILE environment variable:
Set WshShell = WScript.CreateObject("WScript.Shell") ProfilePath = WshShell.ExpandEnvironmentStrings("%USERPROFILE%")
Dave Kreskowiak Microsoft MVP - Visual Basic