Solved

Creating a generic login script for windows 2003 network

Posted on 2008-10-07
7
499 Views
Last Modified: 2013-12-03
Hello,

I am looking to create a generic login script for my 2003 active directory users. I currently have a script for each user to map their network drives etc as required, but would like to replace this with a generic login script.

For information, I currently have username example jbloggs, who's home drive is \\server\jbloggs$ and whos login script is jbloggs.bat so everything is neat and tidy here for scripting purposes.

I realise I need to use a VB script in order to do this, but I dont really have the first clue how to start. I have attached a copy of an existing login script as an example.
@ECHO OFF

@ECHO Welcome Jo Bloggs to %USERDOMAIN% Domain you are using %OS%
 

@ECHO Settting Up Your Login With Server %LOGONSERVER% 
 
 

net time \\server /SET /YES
 

ECHO Setting up user Shares may take a few minutes please wait.
 

if not exist g: net use g: \\fordc001\groups

if not exist s: net use s: \\fordc001\scanned

if not exist h: net use h: \\fordc001\jbloggs$
 

printers.vbs

Open in new window

0
Comment
Question by:forzaaw
  • 4
  • 3
7 Comments
 
LVL 8

Expert Comment

by:mikainz
ID: 22657826
you do not have to user vbscript just to get the username for mapping his homedrive

You can use %username% environment variable.
0
 
LVL 8

Expert Comment

by:mikainz
ID: 22657866
if you need to do more complex tasks like querying active directory, and so on, using vbscript can be recommended.

in vbscript mapping one network drive could function with the following code:
Set fso = CreateObject("Scripting.FileSystemObject")
set oNet = WScript.CreateObject("WScript.Network")
UserName = oNet.UserName
if not fso.folderexists("H:\") then
  oNet.MapNetworkDrive "H:", "\\fordc001\" & UserName
end if


0
 
LVL 1

Author Comment

by:forzaaw
ID: 22657936
In response to your first post, would it not need to be %username% + $ or something like that, being that the home drives are hidden shares?

I shall have a look at the VB part after, but will use the batch if it does what I need.
0
 
LVL 8

Accepted Solution

by:
mikainz earned 500 total points
ID: 22657989
yep
if not exist h: net use h: \\fordc001\%username%$
should work

I recommend not sharing every user home folder.
you could make a folder called \\fordc001\home$
under this share you copy the userfolders and make the following net use command:
if not exist h: net use h: \\fordc001\home$\%username%
so you don't have to create one share for every new user :-)
but you can make it as you like....
0
 
LVL 1

Author Comment

by:forzaaw
ID: 22658000
Just the way we did it in my last place, but yeah I get what your saying. Not too much of an issue with them being hidden. I will try out your solution on a couple of users and see how it goes, then come back and let you know how it went.

Thanks.
0
 
LVL 1

Author Comment

by:forzaaw
ID: 22658014
I am not sure whether or not I should ask a different question, or not here but also if I wanted members of certain groups in AD to get extra drives mapped depending on group membership, do you know how to do this?

i.e You have access to Personnel group, so therefore get a P drive, if not then you dont?

I already have decent NTFS permissions setup on the shared directory, but some things I have mapped seperately for specific reasons.
0
 
LVL 8

Expert Comment

by:mikainz
ID: 22658029
this is a different question as far as I see it.
Your primary question should be answered.

Regards.

0

Join & Write a Comment

For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
Mapping Drives using Group policy preferences Are you still using old scripts to map your network drives if so this article will show you how to get away for old scripts and move toward Group Policy Preference for mapping them. First things f…
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now