+ Post New Thread
Results 1 to 8 of 8
Scripts Thread, Log on Scripts in Coding and Web Development; Can anyone send me an example of a log on script that connects user's drives, adds a few printers and ...
  1. #1
    button_ripple's Avatar
    Join Date
    Dec 2007
    Location
    Luton
    Posts
    346
    Thank Post
    93
    Thanked 20 Times in 18 Posts
    Rep Power
    17

    Log on Scripts

    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!

  2. #2

    mattx's Avatar
    Join Date
    Jan 2007
    Posts
    9,240
    Thank Post
    1,058
    Thanked 1,068 Times in 625 Posts
    Rep Power
    740
    Quote Originally Posted by button_ripple View Post
    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 ]

    Code:
    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
    Printer [ with default ] in VBS

    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"

  3. Thanks to mattx from:

    button_ripple (11th March 2008)

  4. #3
    button_ripple's Avatar
    Join Date
    Dec 2007
    Location
    Luton
    Posts
    346
    Thank Post
    93
    Thanked 20 Times in 18 Posts
    Rep Power
    17
    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

  5. #4

    mattx's Avatar
    Join Date
    Jan 2007
    Posts
    9,240
    Thank Post
    1,058
    Thanked 1,068 Times in 625 Posts
    Rep Power
    740
    Quote Originally Posted by button_ripple View Post
    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.

  6. #5
    cromertech's Avatar
    Join Date
    Dec 2007
    Location
    Cromer by the coast
    Posts
    731
    Thank Post
    177
    Thanked 109 Times in 97 Posts
    Rep Power
    54
    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

  7. #6

    Join Date
    Jul 2007
    Location
    Devon
    Posts
    233
    Thank Post
    8
    Thanked 9 Times in 8 Posts
    Rep Power
    16
    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 )

    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
    We deploy our printers using R2 PMC which is rather useful for this.

  8. #7
    apeo's Avatar
    Join Date
    Sep 2005
    Location
    Lost
    Posts
    1,612
    Thank Post
    95
    Thanked 115 Times in 111 Posts
    Rep Power
    41
    In this thread djones is trying to do what you want.

    Printer and Mapped Drive Script

  9. #8

    Join Date
    Oct 2007
    Location
    Cambridgeshire, UK
    Posts
    306
    Thank Post
    58
    Thanked 23 Times in 20 Posts
    Rep Power
    17
    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

SHARE:
+ Post New Thread

Similar Threads

  1. Help running scripts within scripts
    By SimpleSi in forum *nix
    Replies: 7
    Last Post: 7th March 2008, 09:23 AM
  2. login scripts
    By palmer_eldritch in forum Mac
    Replies: 1
    Last Post: 6th March 2008, 10:47 AM
  3. What do you use for your logon scripts.
    By Kyle in forum How do you do....it?
    Replies: 17
    Last Post: 13th October 2006, 07:54 AM
  4. Scripts, Scripts, Scripts
    By wesleyw in forum Windows
    Replies: 18
    Last Post: 17th July 2006, 02:36 PM
  5. Kix Scripts
    By catbert in forum Scripts
    Replies: 5
    Last Post: 27th September 2005, 01:24 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •