WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Samples from Users
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Command Shared Printer Installer


I made this for use in login scripts to automate printer installs.

Notes:


INSTALL_PRINTER.WBT

;-------------------------------------------------------------
; Install_Printer.wbt
; Created for command line installation of shared printers
; KK (Crypt) 2004
;-------------------------------------------------------------

AddExtender("WWPRT34i.DLL")
Params=""

;Below is for testing without using the command line
;Param0=2
;Param1="/ADD"
;Param2="\\Server\Print Share"

NumParams=Param0
For x = 1 to NumParams
	Params=ItemInsert(Param%x%,x,Params,@TAB)
Next

;Message(Numparams,Params)

a=ItemLocate("/ADD", params, @TAB)
If a!=0
	Params=ItemRemove(a,Params,@TAB)
	Goto Add
EndIf

b=ItemLocate("/DEL", params, @TAB)
If b!=0
	Params=ItemRemove(b,Params,@TAB)
	Goto DEL
EndIf

Goto Error1

:Add
	params=StrReplace(params,"\\","")
	Server=ItemExtract(1,params,"\")
	Printer=ItemExtract(2,params,"\")
	pAddPrtConn(Strcat("\\",Server),Printer)
	Goto End

:Del
	params=StrReplace(params,"\\","")
	Server=ItemExtract(1,params,"\")
	Printer=ItemExtract(2,params,"\")
	pDelPrtConn(Strcat("\\",Server),Printer)
	Goto End

:End
Exit

:Error1
	Msg1=StrCat("Usage:",@CRLF,"Install_Printer.exe  [/ADD]  [/DEL]  [\\Server\Share]")
	Msg2=StrCat(@CRLF,@CRLF,"Examples:",@CRLF,"Install_Printer.exe /ADD \\server\share",@CRLF,"Install_Printer.exe /DEL \\server\share")
	Message("Help",StrCat(msg1,msg2))
	Exit

Article ID:   W16181
File Created: 2004:03:30:15:43:10
Last Updated: 2004:03:30:15:43:10