Solved

Creating a generic login script for windows 2003 network

Posted on 2008-10-07
7
502 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Last week, our Skyport webinar on “How to secure your Active Directory” (https://www.experts-exchange.com/videos/5810/Webinar-Is-Your-Active-Directory-as-Secure-as-You-Think.html?cid=Gene_Skyport) provided 218 attendees with a step-by-step guide for…
This article describes my battle tested process for setting up delegation. I use this process anywhere that I need to setup delegation. In the article I will show how it applies to Active Directory
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 to another domain controller. Log onto the new domain controller with a user account t…
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 …

809 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