tommccann Posted March 31, 2010 Posted March 31, 2010 hi guys, anyone know how to check for a printer on usb then set it as default, must be BAT format tho sadly because i want it to fit in to my current script. we currently map and default network printers like this: IF %Location% == itsuite \\Domain\netlogon\CON2PRT /CD \\Domain\suite using a enivronment variable to set locations. Any ideas?? Thanks
neon Posted March 31, 2010 Posted March 31, 2010 could you not write the code in .vbs and write a line in your .bat file to call the .vbs?
tommccann Posted March 31, 2010 Author Posted March 31, 2010 if you could tell me how to call a vbs from a bat then yea i suppose
neon Posted March 31, 2010 Posted March 31, 2010 call "\\servername\sharename\vbsname.vbs" think it will be easier to do it in .vbs than a .bat file? think you would have to install extras to acheive this from a .bat script. 1
tommccann Posted March 31, 2010 Author Posted March 31, 2010 Dim oPrinters Set shell= WScript.CreateObject("WScript.Shell") Set WshNetwork = WScript.CreateObject("WScript.Network") Set oPrinters = WshNetwork.EnumPrinterConnections For i = 0 to oPrinters.Count - 1 Step 2 if oPrinters.Item(i) = "LPT1:" then wshnetwork.setdefaultprinter oPrinters.Item(i) elseif oPrinters.Item(i) = "USB001" then wshnetwork.setdefaultprinter oPrinters.Item(i) end if Next then called in the bat, o that was easier than i thought! cheers
neon Posted March 31, 2010 Posted March 31, 2010 yh, i was looking for the code to send you, on easter hols for 2 weeks so couldnt get hold of it... try this website Logon Script Printer - AddWindowsPrinterConnection VBScript Method is quite good for things like this...
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