Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting default printer to LPT port with vbscript

Status
Not open for further replies.

uucutech

MIS
Feb 5, 2003
30
US
Hello all,

I was wondering if any of you might know if it's possible to set the default printer, on a large number of machines, to the LPT port with vbscript. Any help would be greatly appreciated.

Thanks!

Dustin
 
i think you might be able to use the MapNetworkDrive function, hmm using LPT1 instead of the drive letter?
perhaps not, perhaps you might be stuck with using the shell

WshShell.Run "NET USE LPT1:....etc", 1, True

returning the default printer, i think this was one of tsuji's posts

prtrname = ""
defaultprtr "computernamehere", prtrname
Msgbox prtrname

function defaultprtr(shost, prtrname)

defaultprtr=0 'error-less return
prtrname="" 'out-param
on error resume next
set svc=getobject("winmgmts:\\" & shost & "\root\cimv2")
set cprtr=svc.execquery("select name, attributes from win32_printer")
for each oprtr in cprtr
if (oprtr.attributes and &h04)=&h04 then prtrname=oprtr.name : exit for
next
if err.number<>0 then defaultprtr=err.number : err.clear : prtrname=""
on error goto 0
set cprt=nothing : set svc=nothing

end function
 
I forgot to mention this is as well.....This needs to be done without using the name of the printer that is connected to LPT1, becuase each printer that is connected to the LPT port o n the various machines might be named something different....so to refresh:

Need printer on every machine set to LPT1 without using the name of the printer.

Once again any comments would be greatly appreciated!

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top