Can anyone send me an example of a log on script that connects user's drives, adds a few printers and sets a default printer?
Thankyou!![]()
Can anyone send me an example of a log on script that connects user's drives, adds a few printers and sets a default printer?
Thankyou!![]()
Logon file - [ .BAT ]
Printer [ with default ] in VBSCode:net time \\stjohns01 /set /yes if %OS%==Windows_NT goto NTWKS net use n: /home net use p: \\stjohns01\apps net use g: \\stjohns01\cse$ net use v: \\stjohns01\cdcache g: cd profiles\kix32 kix32 students.txt c: net use g: /d /y net use f: \\stjohns01\cse$ goto end :NTWKS net use f: \\stjohns01\cse$ /PERSISTENT:NO net use P: \\stjohns01\apps /PERSISTENT:NO net use V: \\stjohns01\cdcache /PERSISTENT:NO net use r: \\stjohns01\resource$ /PERSISTENT:NO net use s: "\\stjohns01\Shared Areas" /PERSISTENT:NO net use w: \\stjohns01\work /PERSISTENT:NO gpupdate :END
Code:Set WshNetwork = CreateObject("WScript.Network") On Error Resume Next Set oPrinters = WshNetwork.EnumPrinterConnections For i = 1 to oPrinters.Count - 1 Step 2 WshNetwork.RemovePrinterConnection oPrinters.Item(i) Next Set WshNetwork = CreateObject("WScript.Network") WshNetwork.AddWindowsPrinterConnection "\\STJohns01\ICT_LASER" WshNetwork.AddWindowsPrinterConnection "\\STJohns01\Brother Laser ICT" WshNetwork.SetDefaultPrinter "\\STJohns01\Brother Laser ICT"
button_ripple (11th March 2008)
how do i get them 2 scripts to run at the same time/work together?
Ideally i want the network drives and printers to be set-up at log on
You could call the VBS printer script from the .BAT file - or use some VBS to map drives instead of using the net use command !! The only reason I have it like that is because thats how the school implemented it before I joined. I have only made very minor changes to the logon process as it works very well.
The logon scripts were in short awful when i first came here. I now have one script that works with the active directory structure. Have a look at http://www.primalscript.com/Free_Tools/index.asp and the logon script generator. With this you can map drives to specific user groups and allocate printers the same way if you wish, however server 2003 R2 lets you deploy printers to specific active directory groups. This means that an it room can have a single printer assigned to it, particularly handy for the students that are able to log on to any computer in any room
This would be our incomplete, but working one, I left the rest out since it's not working 100%, reads a few files and does some things which are student specific just for fun etc.
(Don't ask why I didn't just enumerate the drives, because I don't know)
We deploy our printers using R2 PMC which is rather useful for this.Code:'-------------------------------------- ' South Dartmoor Community College '-------------------------------------- ' Script Name: logon.vbs ' Created On: Wednesday, December 5, 2007 ' Created By: Philip Widdowson ' Last Edited: ' Edited By: '-------------------------------------- On Error Resume Next '-------------------------------------- ' Set up Variables and Create Objects '-------------------------------------- Dim oNet, oFSO, oWSH, ADSysInfo, CurrentUser, oTF Dim FPath, GPath, KPath, MPath, NPath, OPath, PPath, SPath, UPath Dim PE Dim Message, PathToConfig, WallPaperPath, ActiveDesktopPath Const TitleBar = "South Dartmoor Community College" Const crlf = chr (13) & chr (10) Set oNet = CreateObject("WScript.Network") Set oFSO = CreateObject("Scripting.FileSystemObject") Set oWSH = CreateObject("WScript.Shell") Set ADSysInfo = CreateObject("ADSystemInfo") Set CurrentUser = GetObject("LDAP://" & ADSysInfo.UserName) FPath = "\\simsserver\admin" MPath = "\\nx1950-stu\class-files" MPathE = "\\nx1950-stu\class-files\Exams\" NPath = "\\nx1950-adm\staff-pers\" & oNet.UserName OPath = "\\nx1950-stu\students\intake" & Left( oNet.Username, 2 ) & "\" oNet.UserName PPath = "\\nx1950-adm\apps-share" SPath = "\\nx1950-adm\staff-shared" UPath = "\\nx1950-stu\students" '-------------------------------------- ' Random Message '-------------------------------------- Message = "Welcome to " & oNet.UserDomain & ". Please wait while you are logged on." oWSH.Popup Message, 2, TitleBar '-------------------------------------- ' Do Student or Staff specific things '-------------------------------------- If oFSO.DriveExists("F:") Then oNet.RemoveNetworkDrive "F:", True, True If oFSO.DriveExists("G:") Then oNet.RemoveNetworkDrive "G:", True, True If oFSO.DriveExists("K:") Then oNet.RemoveNetworkDrive "K:", True, True If oFSO.DriveExists("M:") Then oNet.RemoveNetworkDrive "M:", True, True If oFSO.DriveExists("N:") Then oNet.RemoveNetworkDrive "N:", True, True If oFSO.DriveExists("O:") Then oNet.RemoveNetworkDrive "O:", True, True If oFSO.DriveExists("P:") Then oNet.RemoveNetworkDrive "P:", True, True If oFSO.DriveExists("S:") Then oNet.RemoveNetworkDrive "S:", True, True If oFSO.DriveExists("U:") Then oNet.RemoveNetworkDrive "U:", True, True If LCase( Left( oNet.UserName, 1 ) ) = "0" Then If Not oFSO.DriveExists("M:") Then oNet.MapNetworkDrive "M:", MPath If Not oFSO.DriveExists("O:") Then oNet.MapNetworkDrive "O:", OPath If Not oFSO.DriveExists("P:") Then oNet.MapNetworkDrive "P:", PPath ElseIf LCase( Left( oNet.UserName, 4 ) ) = "exam" Then If Not oFSO.DriveExists("M:") Then oNet.MapNetworkDrive "M:", MPathE If Not oFSO.DriveExists("O:") Then oNet.MapNetworkDrive "O:", OPath Else If Not oFSO.DriveExists("F:") Then oNet.MapNetworkDrive "F:", FPath, False If Not oFSO.DriveExists("M:") Then oNet.MapNetworkDrive "M:", MPath, False If Not oFSO.DriveExists("N:") Then oNet.MapNetworkDrive "N:", NPath, False If Not oFSO.DriveExists("P:") Then oNet.MapNetworkDrive "P:", PPath, False If Not oFSO.DriveExists("S:") Then oNet.MapNetworkDrive "S:", SPath, False If Not oFSO.DriveExists("U:") Then oNet.MapNetworkDrive "U:", UPath, False End If '-------------------------------------- ' Local NAS Mapping '-------------------------------------- If LCase( Left( oNet.ComputerName, 2) ) = "pe" Then If InStr( StrGroups, PE ) Then oNet.MapNetworkDrive "G:", "\\10.3.47.220\pe" End If
In this thread djones is trying to do what you want.
Printer and Mapped Drive Script
Yeah, and everything seems to work apart from the drive renaming! The same code works in another script I use so it is very frustrating. Haven't had the chance to continue testing this week though.
Dave
My school uses a KIX script to do the job. It seems to work ok so I've not felt the need to change it.
I've trimmed this one down to just show printers and mapped drives.
Code:; KiXtart logon script ; Copyright (C) 2001 Ruud van Velsen. ; All rights reserved. CLS small Color b+/b BOX (0,0,30,79,GRID) ; 'background grid' Color b/n BOX (5,5,25,74,Å) ; 'shadow' of the box Color g+/b BOX (4,4,24,73,FULL) Color r+/b at (2,8) "Hello," at (2,16) @fullname Color y+/b at (3,8) "DO NOT CLOSE THIS WINDOW!!!" Color w+/b AT (7,25) "Userid : " ; display some text strings AT (8,25) "Full name : " AT (9,25) "Privilege : " AT (10,25) "Workstation : " AT (11,25) "Domain : " AT (12,25) "Logon Server : " Color y+/b AT (7,40) @userid ; ...and some macro's AT (8,40) @fullname AT (9,40) @primarygroup AT (10,40) @wksta AT (11,40) @domain AT (12,40) @lserver Dim $RoomName If InStr(@WKSTA, "-") > 0 $RoomName=Left(@WKSTA, (InStr(@WKSTA, "-")-1)) EndIf At (13,25) "Adding Distrib and Drop folders for All Users" use j: "\\share-server\distrib" use k: "\\share-server\drop" ;Make the boardworks folder available to staff as a mapped drive if InGroup("Staff") At (13,25) "Adding Boardworks folder for staff" use l: "\\share-server\Boardworks" endif ; Deletes all mapped printers from machine $junk = DelTree("HKEY_CURRENT_USER\Printers\Connections") AT (14,25) "Adding IT1 Printer" $Junk=AddPrinterConnection ("\\print-server\PRINTIT1") AT (15,25) "Adding IT2 Printer" $Junk=AddPrinterConnection ("\\print-server\PRINTIT2") if InGroup("Staff") AT (20,25) "Adding Staff Printer" $Junk=AddPrinterConnection ("\\print-server\PRINTLAP") ; Find the room that the printer is in and set the default printer accordingly If $RoomName = "IT1" $Junk = SetDefaultPrinter("\\print-server\PRINTIT1") AT (22,25) "Setting IT1 Printer as default" EndIf If $RoomName = "IT2" $Junk = SetDefaultPrinter("\\print-server\PRINTIT2") AT (22,25) "Setting IT2 Printer as default" EndIf sleep 0.5 exit
There are currently 1 users browsing this thread. (0 members and 1 guests)