Solved

Creating a generic login script for windows 2003 network

Posted on 2008-10-07
7
500 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
Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

 
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
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 tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

867 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

20 Experts available now in Live!

Get 1:1 Help Now