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

Posted on 2011-04-29
Last Modified: 2012-05-11
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.
Question by:hendricksonHelp
    LVL 8

    Expert Comment

    C$?   For instance, C$\Users\jdoe75\Desktop\filename.exe

    Author Comment

    how does this change if a different user is logged in?

    Author Comment

    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.
    LVL 15

    Accepted Solution

    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.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Log files are useful in diagnosing and repairing problems.  This is a list of common log files and their standard locations that I've compiled.   While this is not exhaustive, it is a pretty good list that I've found to be useful.  I may update it f…
    This is a little timesaver I have been using for setting up Microsoft Small Business Server (SBS) in the simplest possible way. It may not be appropriate for every customer. However, when you get a situation where the person who owns the server is i…
    This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
    In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now