VBScript - profile path

What is the best way to retrieve the current user's local profile path (documents and settings\username\...) in a script?
I'm working on a script to copy files to a folder in the user's profile.
LVL 3
artthegeekAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
sirbountyConnect With a Mentor Commented:
This should do it - reference the shell's volatile environment...


Dim objEnv
Dim strProfile

Set WshShell = WScript.CreateObject("WScript.Shell")
Set objEnv = WshShell.Environment("Volatile")
strProfile=objEnv("HomeDrive") & objEnv("HomePath")

msgbox strProfile

set objEnv=Nothing
wscript.quit
0
 
artthegeekAuthor Commented:
This looks good -
do I need the  

set objEnv=Nothing
wscript.quit

?
0
 
sirbountyCommented:
set objEnv=Nothing
'supposedly' releases the memory used for that object (I suppose it's debatable - but good coding to terminate these objects to prevent potential memory leaks - although a small script like this shouldn't matter much).

wscript.quit
again, not 'really' necessary - more just standard coding practice so that you control when the script terminates.  It basically says - time to stop processing.
0
 
artthegeekAuthor Commented:
Great stuff - thank you.
0
 
sirbountyCommented:
Happy to have helped. :^)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.