Login Scripts for drive mappings

G

Guest

Im new to Active Directory and im trying to create Login Scripts for drive
mappings. I've been successful with creating login scripts using simple bat
files.

For example; net use n: \\server\users\username

I'm creating the login script Group Policy at the OU level. So of my drive
mapping need to point to a specific directory underneath the users
directories. The mapping has to look like this.

For example; \\server\users\username\dir1

This issue here is that the username is a variable. How do i create a script
so that when a user logs in, the script uses his/her name in the username
place. This can't be done using net use commands in a bat file, can it? Do i
have to user VB Scripts, and if so, can someone tell me how to do this. I
looked at some on Microsofts website, and they looked really long (a couple
of pages) for such a script. I didn't really understand what was going on in
the scripts either.

Thanks in advance,
Shannon
 
F

Florian Frommherz

Howdy Shannon!
Im new to Active Directory and im trying to create Login Scripts for drive
mappings. I've been successful with creating login scripts using simple bat
files.

For example; net use n: \\server\users\username

That is correct. If you always go and map the drives on every startup,
have a look at the "/persistent:no"-flag. Just as a tipp...
For example; \\server\users\username\dir1

This issue here is that the username is a variable. How do i create a script
so that when a user logs in, the script uses his/her name in the username
place. This can't be done using net use commands in a bat file, can it? Do i

Well, have you already tried using the %username% variable? If you try
calling

\\server\users\%username%\dir1

it should work for you as long as it *really* is a logon script. If you
run this as a startup script it will not work, since the script will
then run in the context of the local system.

Just give %username% a try and let us know if it worked for you.

cheers,

Florian
 
G

Guest

Floian, Thanks for the response. You actually got me half way to where i want
to be.
The %username% command only worked part of the way. When the mapping ended
with %username% it worked. I got the logged on users name.

For example; \\server\users\username

That was good. But when the %username% variable was in the middle to the
script, it didn't work. I got no mapping at all.

For example; \\server\users\username\dir1

Any Ideas
 
G

Guest

Are you sure you aren't making any typos? Because overhere it works fine
net use h: \\server\users\%username%\directory

Note: if there are space in the directory name make sure you include "" in
the script:
net use h: "\\server\users\%username%\dir with spaces"

Regards,
Erik
 
G

Guest

Thanks for the reply Erik:

Are your workstations Windows 2000. Im running Windows 2000 sp4. I also got
another reply for another user saying it works for him, but he was running
XP. Thanks for the tip about spaces, good to know; even though there aren't
any in my paths.

Thanks again,
Shannon
 
D

Dave Britt

Another way would be to use a vbscript for example:

Set objNetwork = CreateObject("WScript.Network")
strUser = objNetwork.UserName
objNetwork.MapNetworkDrive "N:","\\server\users\"&strUser
objNetwork.MapNetworkDrive "P:","\\server\"&strUser&"\dir1"

--
Dave Britt
Dave's Weblog
http://davebritt.blogspot.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top