« How come some users can't log in? | Main | Connecting to share without binding to Active Directory »

March 10, 2005

Quick login script

Previously, I used batch files for login scripts, but this time around I decided to give VB script a whirl. Here is a small script that accomplishes some very important things:

' Create printers, set default printer, and map home Directory. ' Dim net Set net = CreateObject("WScript.Network") net.MapNetworkDrive "N:", "\\servername\homedir\" & net.UserName & "\My Documents" net.AddWindowsPrinterConnection "\\servername\Black & White" net.AddWindowsPrinterConnection "\\servername\Copier" net.AddWindowsPrinterConnection "\\servername\Color Printer" net.SetDefaultPrinter "\\servername\Black & White"

The script adds the three lab printers being shared by the print server, sets the default, and also maps the user's home directory. This is the equivalent of:

NET USE N: \\servername\homedir\%USERNAME%\My Documents

Posted by djc6 at March 10, 2005 11:10 AM

Trackback Pings

TrackBack URL for this entry:
http://blog.case.edu/djc6/mt-tb.cgi/635

Comments

I'm about to reimplement printers myself, is there a way to add printers with a batch script?
if not, how do i implement the vbscript? I've never used one

Posted by: Kenny Calero at November 17, 2005 01:04 AM

I'm about to reimplement printers myself, is there a way to add printers with a batch script?
if not, how do i implement the vbscript? I've never used one

Posted by: Kenny Calero at November 17, 2005 01:04 AM

any updates on my comment?

Posted by: Kenny Calero at December 12, 2005 11:00 AM

Hi,

I am a 'new' to Systems Administration and was wondering why would you use a login script to map the home drive when this can be done in 'Active Directory Users & Computers' where you could specify the drive letter etc and the full path with '\\server\sharename\%username%' etc....

Posted by: JuMz at January 31, 2008 12:22 PM

JuMz,

We use the log in script because it is a little more flexible. For instance, we do things such as change which server/sharename the user mounts based on their location on campus. If I did this in the Account Properties, the user would always have the same home directory, which doesn't work for our scenario.

Posted by: David Carlin at January 31, 2008 02:29 PM