locked
Mapping home directory with %username% variable RRS feed

  • Question

  • 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

    Wednesday, August 1, 2012 5:13 PM

Answers

All replies

  • 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

    Wednesday, August 1, 2012 8:05 PM
  • 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

    Thursday, August 2, 2012 2:42 PM
  • You have the correct syntax.  That share must not be available.  Does 'dir \\Server\%username%' work?  Can 'Server' be pinged?
    Thursday, August 2, 2012 3:21 PM
  • Duh the share was hidden with $ so \\server\%username%$ works fine

    • Marked as answer by TorkerTrike Thursday, August 2, 2012 3:51 PM
    Thursday, August 2, 2012 3:51 PM