Jump to content

Recommended Posts

Posted

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

Posted

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.

  • Thanks 1
Posted

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

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



  • 149 What is your preferred operating system (PC)

    1. 1. Operating systems:


      • MacOS
      • Windows 10
      • Windows 11
      • Windows Vista
      • ChromeOS
      • Other (reply)

×
×
  • Create New...