Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Creating a generic login script for windows 2003 network

Posted on 2008-10-07
7
Medium Priority
?
510 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
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
LVL 8

Accepted Solution

by:
mikainz earned 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

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…
A hard and fast method for reducing Active Directory Administrators members.
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 …
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

916 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