Mapping home directory with %username% variable
Hello, Would like to be able to use the NET USE command to map the currently logged in users home directory. I understand the command NET USE X: \\server\share but my issue is that I need to use NET USE X: \\server\%username% So if Jane is logged in and her X: drive NET USE X: \\server\jane somehow gets removed, not showing up in Windows Explorer, she can click a simple Batch file that would re-map her drive instead of logging off and on again. Is it possible to do this in Windows 7 with 2008 R2 servers? When she logs in everything is fine, it's just when users removed drives accidentally it's nice to have a batch file they can resort to before calling for help. Thanks
August 1st, 2012 1:20pm

Yes, the variable "username" is available in the shell meaning you can use it in your bat file and it will translate to whatever the username is.Blogging about Windows for IT pros at www.theexperienceblog.com
Free Windows Admin Tool Kit Click here and download it now
August 1st, 2012 4:12pm

Yes USERNAME is set to be JANE but what is the exact syntax to make this work? If I manually type NET USE X: \\Server\%username% gives me a "System error 53 has occured the network path was not found" Thanks
August 2nd, 2012 10:44am

You have the correct syntax. That share must not be available. Does 'dir \\Server\%username%' work? Can 'Server' be pinged?
Free Windows Admin Tool Kit Click here and download it now
August 2nd, 2012 11:23am

Duh the share was hidden with $ so \\server\%username%$ works fine
August 2nd, 2012 11:53am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics