Jump to content

Recommended Posts

Posted
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! :D

 

Logon file - [ .BAT ]

 

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

 

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"

  • Thanks 1
Posted
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.

Posted
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
Posted

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 :))

 

'--------------------------------------
' 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.

Posted

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...