retrieve local user profile path with vbscript
I need a windows vbscript to retrieve local user profile path.
Thanks
Windows Forum
I need a windows vbscript to retrieve local user profile path.
Thanks
by atwizrane Accepted solution
by chris910 Accepted solution
this will print the profile path in DOS
echo %userprofile%
I suspect that the same system variable is available in VBScript.
by dan.cox Accepted solution
Const HKEY_LOCAL_MACHINE = &H80000002
Set objRegistry=GetObject("winmgmts:\\" & strLocalPC & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList"
objRegistry.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubkeys
For Each objSubkey In arrSubkeys
strValueName = "ProfileImagePath"
strSubPath = strKeyPath & "\" & objSubkey
objRegistry.GetExpandedStringValue HKEY_LOCAL_MACHINE,strSubPath,strValueName,strValue
LogAction "Deleting Temporary Internet files for " & strValue & "\Local Settings\Temporary Internet Files\*.*"
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.DeleteFile(strValue & "\Local Settings\Temporary Internet Files\*.*")
Next
by thoades Accepted solution
You can call any DOS "environment" variable using the following method within VBS without having to interrogate AD
Set objShell = CreateObject("WScript.Shell")
userProfilePath = objShell.ExpandEnvironmentStrings("%UserProfile%")
just swap the "%UserProfile%" in the above line to which ever DOS environment variable it is you need.
This discussion is closed to new replies.
Sort by Trending