itgeek Posted April 29, 2010 Posted April 29, 2010 Hi we are running the script below but when a student is on they get printers from other rooms? Option Explicit DIM RegEntry, ComputerName RegEntry="HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName\ComputerName" ComputerName = ReadRegValue(RegEntry) if InStr(1,ucase(ComputerName),"LAB1-",vbTextCompare) > 0 then call SetPrinter("\\LAB1\LaserJet") if InStr(1,ucase(ComputerName),"LAB2-",vbTextCompare) > 0 then call SetPrinter("\\LAB2\LaserJet") if InStr(1,ucase(ComputerName),"OFFICE-",vbTextCompare) > 0 then call SetPrinter("\\OFFICE\LaserJet") 'so on and so forth. wscript.quit ' *** This subroutine installs and sets the default printer Sub SetPrinter(ByVal PrinterPath) DIM WshNetwork Set WshNetwork = CreateObject("WScript.Network") WshNetwork.AddWindowsPrinterConnection(PrinterPath) WshNetwork.SetDefaultPrinter Printerpath end sub ' **** This function returns the data in the registry value Function ReadRegValue(ByVal RegValue) DIM WSHShell Set WSHShell = WScript.CreateObject("WScript.Shell") ReadRegValue="" On Error Resume Next ReadRegValue= WSHShell.RegRead(RegValue) End Function
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now