faza Posted May 17, 2006 Posted May 17, 2006 Hi All, I am currently using Con2Prt to connect the users to the dedicated printer in their IT room. But the problem i am having is that sometimes if the user goes into a different IT room it will pick up the previous printer from the previous room. Is there a solution to this or an alternative method or program i can use like VBS but i am new to VBS and it all all confuses me. Currently the con2prt file checks the room in the autoexec.bat and then using the batch file connects to the dedicated printer. But sometimes as i say it still connects to the previous printer that was used. Can anyone please help Steve
alan-d Posted May 17, 2006 Posted May 17, 2006 An extract from ours is: on error resume next Set shell= WScript.CreateObject("WScript.Shell") Set WshNetwork = WScript.CreateObject("WScript.Network") dim Counter, PrinterPath dim strResult, strLocation, strComputer 'Remove All Network Printers. Set oPrinters = WshNetwork.EnumPrinterConnections FOR Counter = 0 to oPrinters.Count - 1 IF mid(oPrinters.Item(Counter), 1, 2) = "\\" THEN PrinterPath = oPrinters.Item(Counter) WshNetwork.RemovePrinterConnection PrinterPath, True, True End If Next 'Add Network Printers based on Location set in Environment Variables strLocation = shell.ExpandEnvironmentStrings("%LOCATION%") strComputer = shell.ExpandEnvironmentStrings("%COMPUTERNAME%") select case strLocation case "ASTLaptop" addPrinter "\\server2\hplassta",true case "ITOffice" addPrinter "\\server2\HP4100IT",true addPrinter "\\server2\copyroom1232",false addPrinter "\\server2\ILCStudent",false end select function addPrinter(strConnectString,isDefault) if strConnectString <> "" then strResult = WshNetwork.AddWindowsPrinterConnection(strConnectString) if isDefault then WshNetwork.SetDefaultPrinter strConnectString end if end if end function
apeo Posted May 17, 2006 Posted May 17, 2006 In your script do you remove all previous network printers ie \\SERVER1\APPLIC\CON2PRT\CON2PRT /F As for the rest of your question check the following thread out. Previous thread
faza Posted May 17, 2006 Author Posted May 17, 2006 To the ist reply does that code contain deleting any printers currently installed?
faza Posted May 17, 2006 Author Posted May 17, 2006 To the 2nd reply yes in the script it does say remove all current printer connections
apeo Posted May 17, 2006 Posted May 17, 2006 If that is the case then there is a problem at startup i imagine as its not doing what its supposed to be doing. As for the script that is posted, the answer to your question is No, it is the script version of con2prt and it removes all network printers then adds in the ones you want based on location. However the script can be tweaked to remove specific printers.
krisd32 Posted May 19, 2006 Posted May 19, 2006 put con2prt /? in the command prompt this will give you a list of things it's able to do! i had this problem at 1 of my schools i simply put \\SERVER1\APPLIC\CON2PRT\CON2PRT /F at the top of my script before it did anything else and it seemed to cure the problem!
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