Windows 7 - Users Home Directory

Started by bmclellan, September 12, 2013, 06:22:15 PM

Previous topic - Next topic

bmclellan

Hello,

I can't seem to find the function which would tell me what the persons home directory is when running a winbatch script.

i.e. c:\users\<my name>\My Documents

I've been away for a while, and my debug scripts used to just write to c:\temp, but I'm thinking those days are far behind me now!


Thanks
Barry

Russell_Williams

Are you wanting the local Profile folder? There is a environment variable USERPROFILE on all desktops that points to that.

Or there is an environment variable "TEMP" that usually points to that same place and a temporary folder under it (be aware that path can contain spaces in it)

Or the Home directory in an Active Directory network?

td

Take your pick.

Code (winbatch) Select

strProfile = Environment("USERPROFILE")
strTemp = Environment("TEMP")
strDocuments = ShortCutDir("{FDD39AD0-238F-46AF-ADB4-6C85480369C7}")
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

bmclellan

This is great, thanks for your examples!!


Barry