Code Allows Restricted NT Clients to Change Printer Configuration
Keywords: change printer configuration
; Name: PrintCfg.wbt
; Discription: Windows NT Workstation Printer config app.
; Comments: Allows restricted NT clients to change printer config.
; Extenders: WWPRT34I.DLL, WWWNT34I.DLL
Ver = "1.0.0"
Gosub Init
While ButtonPushed <> 0 ; Keep looping till they Exit
;find out the default printer
Default_Printer = pGetDefPrtInf (1)
;find out the list of currently installed printers
Current_Printers = pGetPrtList( 0)
ButtonPushed = Dialog("PrintCfg")
Select ButtonPushed
Case 2
Gosub AddPrinters
break
Case 3
;Only try to remove the printer if they have selected one.
If ItemCount(Current_Printers,@tab) == 1 then
Gosub RemovePrinter
Else
Message("Error!","Please select a printer to be removed.")
EndIf
break
Case 4
;check to see if they have selected one printer to be made default
If ItemCount(Current_Printers,@tab) == 1 then
Gosub ChangeDefault
Else
Message("Error!","Please select a printer to make the default.")
EndIf
break
Case 5
Gosub Help
break
EndSelect
EndWhile
:end
exit
;************************************************
;*************** INIT SECTION ****************
;************************************************
;This section sets up the dialog box and any settings that may be needed.
;Expects:
;Outputs:
:Init
;Add required extenders
AddExtender("WWPRT34I.DLL")
AddExtender("WWWNT34I.DLL")
;Setup dialog box.
PrintCfgFormat=`WWWDLGED,5.0`
PrintCfgCaption=`Printer Configuration (ver 1.0)`
PrintCfgX=196
PrintCfgY=74
PrintCfgWidth=256
PrintCfgHeight=112
PrintCfgNumControls=8
PrintCfg01=`68,22,184,86,ITEMBOX,Current_Printers,DEFAULT`
PrintCfg02=`70,6,180,DEFAULT,VARYTEXT,Default_Printer,""`
PrintCfg03=`4,26,58,DEFAULT,PUSHBUTTON,DEFAULT,"&Add Printer",2`
PrintCfg04=`4,40,58,DEFAULT,PUSHBUTTON,DEFAULT,"&Remove Printer",3`
PrintCfg05=`4,54,58,DEFAULT,PUSHBUTTON,DEFAULT,"&Change Default",4`
PrintCfg06=`4,80,58,DEFAULT,PUSHBUTTON,DEFAULT,"&Help",5`
PrintCfg07=`4,94,58,DEFAULT,PUSHBUTTON,DEFAULT,"E&xit",0`
PrintCfg08=`30,6,38,DEFAULT,STATICTEXT,DEFAULT,"Default Printer:"`
ButtonPushed = -1
;Allows only one selection on List box on the dialog box.
IntControl(33, 0, 0, 0, 0)
;Find out computer name for finding list of installed printers
MachineKey = RegOpenkey(@REGMACHINE, "SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName")
ComputerName = StrCat("\\",RegQueryValue(MachineKey, "[ComputerName]"))
RegCloseKey(MachineKey)
Return
;************************************************
;*************** ADD PRINTERS ****************
;************************************************
;This section lists all printers on a remote server and allows the user to select one and installs it.
;Expects:
;Outputs:
:AddPrinters
;Find out a list of printers on the remote server
Printers = wntResources("\\Jack_Daniels", 2, 2, 0)
AddPrinters = ""
While AddPrinters == "" ; while they have not chosen a printer (Can be more than one)
AddPrinters = AskItemList("Printers", Printers, @tab, @sorted, @multiple)
EndWhile
;For each printer they have selected add the conection.
For Item = 1 to ItemCount(AddPrinters,@tab)
Printer = ItemExtract(Item,AddPrinters,@tab)
pAddPrtConn("Jack_Daniels", ItemExtract(4,Printer,"\"))
Next
Return
;************************************************
;************* REMOVE PRINTERS ***************
;************************************************
;This section removes a selected printer
;Expects: Current_Printers - Printer to remove
;Outputs:
:RemovePrinter
;pDelPrtConn only wants the printer name so we have to trim off the rest of the guff
RPrinter = StrTrim( ItemExtract(4,ItemExtract(1,Current_Printers,"-"),"\") )
pDelPrtConn( "Jack_Daniels", RPrinter)
Return
:ChangeDefault
;************************************************
;************** CHANGE DEFAULT ****************
;************************************************
;This section changes the default printer to the current selected one.
;Expects: Current_Printers - Printer to make default
;Outputs:
pSetDefPrt (Current_Printers)
Return
:Help
Message("Printer Configuration Help","This is currently a quick and dirty application for%@crlf%configurating the printers on NT workstations.")
Return
Article ID: W14190
Filename: Allows restricted NT clients to change printer config.txt