Link to home
Start Free TrialLog in
Avatar of Jaime Campos
Jaime CamposFlag for United States of America

asked on

How do you setup a logon script for Win2k8 AD?

Hello,

I've setup a new DC and Fileserver with an existing Fileserver. I will copy over all data with Robocopy from old Fileserver to my new Fileserver. I'm interested in finding out how to properly map a new network drive pointing to my new share directory folders on my users desktops. I've done some research and found some information, however I want to ensure I'm doing it correctly within a Win2k8 server.

Thanks,

nimdatx
Avatar of Aaron
Aaron
Flag of United States of America image

Create a batch file .bat in the sysvol directory of the domain controller that contains the new mappings.  In Active Directory adjust the field under the profile tab for the users to utilize the new batch file (just put the file name, not the full path).  When each user logs in it will run that batch file and map the drives.
ASKER CERTIFIED SOLUTION
Avatar of Aaron
Aaron
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
Avatar of Mike Kline
One nice thing is that you can also use group policy preferences to map drives

http://blogs.technet.com/b/grouppolicy/archive/2009/02/11/gp-preferences-will-reduce-logon-scripts-mapping-drives.aspx

GPP can help reduce or even eliminate all login scripts

Thanks

Mike
SOLUTION
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
Avatar of Jaime Campos

ASKER

Can I use a .vbs extension? Also what if the users drive letter is taking up and my script says to use a specific letter? Is there a way to force to use first availible?
You could use .vbs and then create a GPO to deploy the script.
I would use a batch file that calls the .vbs script.  I don't know of a way to force first available.  I often set each map drive to use the "del" command first to make sure we have the same map drives across the company.  For the user share drive I would recommend setting that up through the profile tab in AD, rather than the login script.
Can I use this script within notepad and save as a batch file? My server is 192.168.1.173 and share name is Renal Common.

' Map network drive script
Set objNetwork = CreateObject("WScript.Network")
objNetwork.MapNetworkDrive "S:" , "\\192.168.1.173\Renal Common"
You can setup a vbscript and I can add that zone if you want to go that route.  I you are newer to vbscript or scripting I'd definitely consider using/testing GPP for mappings.

Thanks

Mike
Might just be easier to use the "NET USE" command for a .bat file.

From Microsoft:

To assign the disk-drive device name E: to the Letters shared directory on the \\Financial server, type:
net use e: \\financial\letters

To assign (map) the disk-drive device name M: to the directory Mike within the Letters volume on the \\Financial NetWare server, type:
net use m: \\financial\letters\mike

To connect the user identifier Dan as if the connection were made from the Accounts domain, type:
net use d:\\server\share /user:Accounts\Dan

To disconnect from the \\Financial\Public directory, type:
net use f: \\financial\public /delete

To connect to the resource memos shared on the \\Financial 2 server, type:
net use k: "\\financial 2" \memos

To restore the current connections at each logon, regardless of future changes, type:
net use /persistent:yes
I use a vbscript as a login script.  Here is an example of some lines in my script.

If you want to use a batch file, use the net use command instead.
'============================================
'Removes any existing network drives
'============================================
WSHNetwork.RemoveNetworkDrive "G:"
WSHNetwork.RemoveNetworkDrive "I:"
WSHNetwork.RemoveNetworkDrive "J:"
WSHNetwork.RemoveNetworkDrive "O:"
WSHNetwork.RemoveNetworkDrive "P:"
WSHNetwork.RemoveNetworkDrive "Q:"
WSHNetwork.RemoveNetworkDrive "S:"
WSHNetwork.RemoveNetworkDrive "T:"
WSHNetwork.RemoveNetworkDrive "U:"
WSHNetwork.RemoveNetworkDrive "V:"
WSHNetwork.RemoveNetworkDrive "W:"
WSHNetwork.RemoveNetworkDrive "X:"
WSHNetwork.RemoveNetworkDrive "Y:"
WSHNetwork.RemoveNetworkDrive "Z:"

'============================================
' If Logic Testing for single user based mapped drives
'============================================
If WshNetwork.UserName = "bev" Then
objNetwork.MapNetworkDrive "J:", "\\10.90.10.91\busadm"
End If

'===================================================================
' If logic testing strGroup for the values in Const groups
'===================================================================
If InStr(strGroup, lcase(transportation)) Then
'WScript.Echo "Transportation"							'REM this out when not testing
objNetwork.MapNetworkDrive "T:", "\\transportation\transport"
End If

'===============
'Quit the Script
'=============== 
 wscript.quit

Open in new window

You can easily force the first available drive letter using an asterisk,
net use * \\server\share

HOWEVER, I would advise against this.  If you start forcing the next available drive letter, you start confusing people and making it difficult on your technicians to support your users.  When users know the Departmental share is on G: (for example), then the support staff can say to reference G: and they know what the user is talking about when the user says there is a problem with the G: drive.  If you force the next availble letter, then some users may have it at G:, others at H:, others at I: and still others at J: or another letter... now Jane asks Joe, where is the report on sales, Joe says H:, but for jane it's J, now they are both confused.
Ok so, I open up notepad and do a net use X:\\server\share and save as .bat on my desktop? How do I use AD to push this out?

mkline71,

How do I use GPP for mapping and is this more reliable then a logon script?

Thanks,

nimdatx
SOLUTION
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
mkline71,

Do I need to install anything on the user side (desktop)?
One more thing....can I set home folder to new share (files users need) or is that for their own folder with their specific documents?
SOLUTION
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