Solved

Creating a generic login script for windows 2003 network

Posted on 2008-10-07
7
503 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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
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

Featured Post

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Always backup Domain, SYSVOL etc.using processes according to Microsoft Best Practices. This is meant as a disaster recovery process for small environments that did not implement backup processes and did not run a secondary domain controller that ne…
Recently, Microsoft released a best-practice guide for securing Active Directory. It's a whopping 300+ pages long. Those of us tasked with securing our company’s databases and systems would, ideally, have time to devote to learning the ins and outs…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

733 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