Link to home
Start Free TrialLog in
Avatar of Steven
StevenFlag for United States of America

asked on

Map drives upon logon...

Objective:
Automatically map specific network drives to all domain users.  What's the best way of doing this?  Right now the organization is using a login.kix script but it seems to be a bit buggy.  Thanks.
Avatar of Andrew Porter
Andrew Porter
Flag of United States of America image

A batch or java file would get the job done nicely.

net use k: /delete
net use l: /delete
net use u: /delete

net use l: \\server\share
net use k: \\server\share
net use u: \\server\%username%$

something like this.
What you are doing (mapping using a script) is probably still the most common way.  You can use batch files, vbscript, kix, etc.
For long term I'd think about moving to use group policy preferences and not having to depend on login scripts
Group policy MVP Darren has a good overview of GPP here:
http://www.gpoguy.com/FAQs/Whitepapers/tabid/63/articleType/ArticleView/articleId/7/Group-Policy-Preferences-Overview-Whitepaper.aspx
Thanks
Mike
Yes, andeporter is correct, that is how i would do it as well. Just in case you need to full steps:

Start > Run > type gpedit.msc and click okay.

go to user configuration, windows settings, scripts logon/logoff

click on logon.

click add.. then show files. Create your bat file here, and save it. then, add it to the login scripts windows, and hit okay to exit the window.

Now, click start > Run > type cmd and hit okay

type gpupdate /force to update the group policy, and test it on your clients.

If all mapped drives are being created through a login script, make the bat file look like this:
net use * /delete /yes
net use g: \\servername\share
net use h: \\servername\share

Open in new window

Avatar of Steven

ASKER

does net use * /delete /yes simply delete all current mapped drives?
does net use * /delete /yes simply delete all current mapped drives?
Yes, that is right.
Thanks
Mike
Avatar of Steven

ASKER

okay, let's get crazy.
can i define mapped drives per user group?
for example:
members of the accounting security group get h:\accounting
members of the developers security group get g:\projects
everyone gets j:\applications & i:\printers
Avatar of zelron22
zelron22

To do it by group you either have to set up different scripts/policies, use something like Kixtart, or you could use someting like IFMEMBER.EXE which can be called from a batch file so you can have one script for everyone.
@echo off
 
rem ** This is the Company Microsoft Windows 2000 Logon script.  
rem ** We are using the 'ifmember.exe' admin tool to map drives based
rem ** on security groups.  
 
ifmember "_company"
if not errorlevel 1 goto quit
net use m: \\server\company /persistent:no
:quit
 
ifmember "_Legal"
if not errorlevel 1 goto quit
net use j: \\server\Legal /persistent:no
:quit
 
ifmember "_Legal Library"
if not errorlevel 1 goto quit
net use j: \\server\Legal /persistent:no
:quit

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Mike Kline
Mike Kline
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
These will work, i usually make seperate scripts and policies and apply them to different OU's in Active Directory.
We have moved away from kix for years and have been using ADSI. We only have one simple VBS script and launch by GPO. But regardless what you use, you may want to consider move away from drive mappings. This is another accomplishment we have made for many years since Windows 2000. Why use drive mappings? It's meaningless. of course, if you have some legacy application required a drive mapping, then you can always make an exception. Otherwise, most drive mappings are for group share and home shares etc. It should be meaningful. What we do is do them all in shortcuts with meaningful name such as "Human Resource" instead of "H:". For some users H: could be Home drive or something else, quite confusing. Afterall, what if you have 20+ mappings, what drive letter are you going to call them? That also slow down logon as it attempt to connect to the server for each drive mapping. Then later when you move server data around due to retirement or replacement of server etc, you need to always update your script. With shorcut, you only update shortcut. You can certainly assing shortcut(s) to specific group in the domain, much more direct and simpler to manage than those drive mappings...
Avatar of Steven

ASKER

Here is my current Kix logon.bat:

I want to delete all mapped drives before this script takes hold.
What's the correct command?
IF INGROUP("ATX\Acme-PA") = 1
	$HOMEDIR = "\\svr-fp01\" + @USERID + "$"
ELSE
	$HOMEDIR = "\\svr-fp01\" + @USERID + "$"
ENDIF
 
USE P: $HOMEDIR
USE G: "\\svr-fs01\APPS"
USE S: "\\svr-fp01\Corporate General"
USE V: "\\svr-fp01\G2 Portal"
 
 
; ***** Map Drives for Department mappings *****
 
IF INGROUP("Acme\HR") = 1
	USE F: "\\svr-fp01\HR"
ENDIF
 
IF INGROUP("Acme\PPM") = 1
	USE H: "\\svr-fp01\Common"
ENDIF
 
IF INGROUP("Acme\Exec") = 1
	USE I: "\\svr-fp01\Exec"
ENDIF
 
IF INGROUP("Acme\IT") = 1    
	USE I: "\\svr-fp01\IT"
ENDIF
 
IF INGROUP("Acme\Legal") = 1
	USE J: "\\svr-fp01\Legal"
 
EXIT

Open in new window

If you want to keep the same format, you would just put "/DELETE after each "USE" line.
For example, USE I: /DELETE

Or just use this to blow off all drive mappings
USE "*"/DELETE
Avatar of Steven

ASKER

I used USE "*"/DELETE and it only Disconnected the network drive.

See screen shot,   I want these additional drives to drop off the face of the earth.
2-18-2009-11-57-39-PM.png
Avatar of Steven

ASKER

bump to the above post.
want the drive removed, not just disconnected
Net use x: /delete should delete the drive, not just disconnect it.

If it isn't deleting it, put a pause command at the end of the script or direct the output of the script to a .txt file so you can see what's happening and why it isn't being deleted.
Avatar of Steven

ASKER

Put a pause command at the end of the entire kix script or what?
could you please define a little better please?