Search code examples
windowsbatch-filefileshare

Windows 10 .bat script for mapping a file share that contains a folder the same name as their A.D. username


I have a network file share for each user: \\network_share\users\jdoe where "jdoe" is their active directory account username.

Is there an environment variable that would work for this?

I attempted:

net use H: \\network_share\users\%USERPROFILE%

But that didn't work. Any help is appreciated.


Solution

  • You need a double backslash in the beginning of the network path. Also USERPROFILE is a path, not a name. Here:

    net use H: \\network_share\users\%USERNAME%
    

    Use set | find "jdoe" to search for a specific string in the environment variables, both names and values.