chrbb Posted July 11, 2008 Posted July 11, 2008 Posted this the other night just before the big 'meltdown' at fasthosts hope it wasn't yet another printer script request that did it:o I have two seperate vbs scripts at logon, one to delete networked printers and one to connect to network printers, what I really want but am too dim to do it, is one script that will delete networked printers if they exist and connect/install currently used network printers. Nice to be back - well done!
roty80 Posted July 11, 2008 Posted July 11, 2008 (edited) could try: On error resume next 'Remove's All Network Objects (Printers and Drives) Set WshNetwork = WScript.CreateObject("WScript.Network") Set oDrives = WshNetwork.EnumNetworkDrives Set oPrinters = WshNetwork.EnumPrinterConnections For i = 0 to oDrives.Count - 1 Step 2 WshNetwork.RemoveNetworkDrive oDrives.Item(i),true,true Next For i = 0 to oPrinters.Count - 1 Step 2 WshNetwork.RemovePrinterConnection oPrinters.Item(i+1) Next '----------------------------------------------------------- 'Map Printers Based On Computer OU Membership Set objSysInfo = CreateObject("ADSystemInfo") strName = objSysInfo.ComputerName arrComputerName = Split(strName, ",") arrOU = Split(arrComputerName(1), "=") strComputerOU = arrOU(1) Set objNetwork = CreateObject("WScript.Network") Select Case strComputerOU '----------------------------------------------------- Case "OU name" objNetwork.AddWindowsPrinterConnection "\\server\printername" objNetwork.SetDefaultPrinter "\\server\printername" Obviously put your OU's and printer share names in and repeat for all printers and OU's Edited July 11, 2008 by roty80 spelling 1
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