Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 436
  • Last Modified:

How do I make a dynamic windows path that is unique for every user that logs into a computer?

I need to dynamically get the path name of a file located on the user's desktop.  This path name will be different for every user.  For example, if user jdoe75 is logged in, the path to the desktop would be "C:\Users\jdoe75\Desktop\filename.exe" then if user lbird15 logs in, the path would be "C:\Users\lbird15\Desktop".

I need a way to access the desktop file of whomever is logged in at that moment.  I know it has something to do with windows variables and percent signs, but I couldn't find a specific reference for my exact issue.
  • 2
1 Solution
C$?   For instance, C$\Users\jdoe75\Desktop\filename.exe
hendricksonHelpAuthor Commented:
how does this change if a different user is logged in?
hendricksonHelpAuthor Commented:
Like I said, I know it has something to do with percent signs and windows environment variables.  I would probably look something like this:  c:\users\%username%\desktop\filename.exe
I just don't know what the variable is that I should be using.
greg wardSystems EngineerCommented:
Its pretty close and much better than  c:\users\%username%\ as when you have more than one domain with the logon the same the username for the second domain becomes username.domain :(
the below link takes this even further.



Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now