retrieve local user profile path with vbscript

By atwizrane ·
I need a windows vbscript to retrieve local user profile path.


This conversation is currently closed to new comments.

4 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Collapse -

the DOS command to retreive this is ...

by Chris910 In reply to retrieve local user profi ...

this will print the profile path in DOS

echo %userprofile%

I suspect that the same system variable is available in VBScript.

Collapse -

Here you go.

by dan.cox In reply to retrieve local user profi ...

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\*.*")

Collapse -

VB Solution

by Thoades In reply to retrieve local user profi ...

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.

Back to Windows Forum
4 total posts (Page 1 of 1)  

Related Discussions

Related Forums