Author Topic: Windows 7 - Users Home Directory  (Read 2605 times)

bmclellan

  • Newbie
  • *
  • Posts: 28
Windows 7 - Users Home Directory
« on: September 12, 2013, 06:22:15 pm »
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

  • Newbie
  • *
  • Posts: 11
Re: Windows 7 - Users Home Directory
« Reply #1 on: September 13, 2013, 06:45:37 am »
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

  • Tech Support
  • *****
  • Posts: 3016
    • WinBatch
Re: Windows 7 - Users Home Directory
« Reply #2 on: September 13, 2013, 07:02:37 am »
Take your pick.

Code: Winbatch
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

  • Newbie
  • *
  • Posts: 28
Re: Windows 7 - Users Home Directory
« Reply #3 on: September 13, 2013, 01:23:45 pm »
This is great, thanks for your examples!!


Barry