How to script access with %username%

  • Thread starter Thread starter Moritz
  • Start date Start date
M

Moritz

I need to create a batch file or script to enable users to map a drive to their home directory via VPN. I have tried the following:

net use H: \\servername\home\%username% /persistent:no

This has been unsuccessful. Is there a way to accomplish this? I suppose I need a prompt for username, as their login name on the remote workstation may be different from that on the LAN.

Thanks for any help!
 
First, if you don't have WINS set up (and specified in the VPN properties),
you'll need an LMHOSTS file configured properly on each machine in order to
do name resolution. Make sure you also specify the domain with the 0x1b
entry properly....this can be tricky.

I don't think you'll be able to use the %username% variable in your
case...will need a different file for each user. If you need to specify a
different username, you can use

net use h: \\server\share\username /persistent: no /user:domain\user

and they'll be prompted. Only need to do it for one of the net use
lines....the first one - it should cache.
 
Unsuccessful why ?
Are you sure that that NetBIOS name is resolvable
on the VPN client ?
If NetBIOS name "servername" is on machine with
FQDN hostname "someserver.your.domain.com"
did you try
\\someserver.your.domain.com\home\%username%
??
Are you sure that the NetBT ports are being allowed
in the VPN circuit ?

--
Roger Abell
Microsoft MVP (Windows Server System: Security)
MCSE (W2k3,W2k,Nt4) MCDBA
I need to create a batch file or script to enable users to map a drive to
their home directory via VPN. I have tried the following:

net use H: \\servername\home\%username% /persistent:no

This has been unsuccessful. Is there a way to accomplish this? I suppose I
need a prompt for username, as their login name on the remote workstation
may be different from that on the LAN.

Thanks for any help!
 
Back
Top