KiXforms Forum Index KiXforms
The Forum for the KiXforms Community
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Quick Links 
Site News
Downloads
Documentation
Donations
Script Archive
Tracking Systems

Kixforms AddPrinter()

 
Post new topic   Reply to topic    KiXforms Forum Index -> Script Archive
View previous topic :: View next topic  
Author Message
agconmet
KiXforms Follower
KiXforms Follower


Joined: 12 May 2003
Posts: 15

PostPosted: Wed May 14, 2003 11:20 pm    Post subject: Kixforms AddPrinter() Reply with quote

This Kixforms app is based on the AddPrinter() UDF on Kixtart.org

http://www.kixtart.org/board/ultimatebb.php?ubb=get_topic;f=12;t=000404

Code:
BREAK ON
GO C:      CD "C:\"
$CV="CURRENTVERSION"
$HKCU="HKEY_CURRENT_USER"
$HKLM="HKEY_LOCAL_MACHINE"
$PWVER="1.00"
$MS="MICROSOFT"
$SMWCV="SOFTWARE\Microsoft\Windows\CurrentVersion"

IF INSTR(@PRODUCTTYPE,"Server") OR INSTR(@PRODUCTTYPE,"Domain Controller")
   $FUNCTOEXECUTE=SPLIT("COMPUTERINFO,PRINTERLIST",",")
ELSE
   $FUNCTOEXECUTE=SPLIT("COMPUTERINFO,PRINTERLIST",",")
ENDIF

$FORMROOT=CREATOBJECT("KIXTART.FORM")
IF @ERROR
   $NUL=SETCONSOLE("SHOW")
   "KIXFORMS.DLL NOT INSTALLED/REGISTERED" ?
   IF @INWIN="1"
      SHELL "%COMSPEC% /C REGSVR32 /S C:\NETWORK\KIXFORMS.DLL"
   ELSE
      SHELL "%COMSPEC% /C %WINDIR%\SYSTEM\REGSVR32 /S C:\NETWORK\KIXFORMS.DLL"
   ENDIF
   $FORMROOT=CREATOBJECT("KIXTART.FORM")
   IF @ERROR
      "Unable To Register KIXFORMS.DLL, Please Contact The IT Network Department." ??
      "Press ENTER To Continue..." ?
      GET $S
      EXIT(1)
   ENDIF   
ENDIF

$NUL=SETCONSOLE("HIDE")
;$NUL=SETCONSOLE("SHOW")
CLS
$FORMMAIN=CREATEOBJECT("KIXTART.FORM")
$FORMMAIN.SIZE=700,600
$FORMMAIN.BACKCOLOR=255,255,255
$FORMMAIN.SYSMENU=0
$FORMMAIN.TEXT="COMPANY1 Network Printer Wizard $PWVER"
$FORMMAIN.CENTER

$FRAMEWELCOME=$FORMMAIN.FRAME
$FRAMEWELCOME.SIZE=680,50
$FRAMEWELCOME.CENTER
$FRAMEWELCOME.TOP=0
$FRAMEWELCOME.TEXT="Welcome:"

$LABELWELCOMELINE1=$FRAMEWELCOME.LABEL("Welcome to the COMPANY1 Network! This program will install the network printer(s) that you pick from the list.",5,20,0,20)
$LABELWELCOMELINE1.ALIGNMENT=1

$FRAMECOMPUTERINFO=$FORMMAIN.FRAME
$FRAMECOMPUTERINFO.SIZE=285,125
$FRAMECOMPUTERINFO.CENTER
$FRAMECOMPUTERINFO.TOP=$FRAMEWELCOME.BOTTOM+5
$FRAMECOMPUTERINFO.LEFT=7
$FRAMECOMPUTERINFO.TEXT="Computer Information:"

$FRAMEPRINTERACTION=$FORMMAIN.FRAME
$FRAMEPRINTERACTION.SIZE=285,125
$FRAMEPRINTERACTION.CENTER
$FRAMEPRINTERACTION.TOP=$FRAMECOMPUTERINFO.BOTTOM+5
$FRAMEPRINTERACTION.LEFT=7
$FRAMEPRINTERACTION.TEXT="STEP 2: Quit Program When Finished:"

$FRAMEPRINTERLIST=$FORMMAIN.FRAME
$FRAMEPRINTERLIST.CLIENTWIDTH=385
$FRAMEPRINTERLIST.CLIENTHEIGHT=430
$FRAMEPRINTERLIST.SIZE=385,430
$FRAMEPRINTERLIST.CENTER
$FRAMEPRINTERLIST.TOP=$FRAMEWELCOME.BOTTOM+5
$FRAMEPRINTERLIST.LEFT=302
$FRAMEPRINTERLIST.TEXT="STEP 1: Click On A Network Printer && It Will Be Automatically Installed:"

$IMAGELOGO=$FORMMAIN.IMAGE("@SCRIPTDIR\COMPANY1.BMP",47,465,0,0)
$IMAGELOGO.BORDERSTYLE=0

$FRAMESTATUS=$FORMMAIN.FRAME
$FRAMESTATUS.SIZE=385,70
$FRAMESTATUS.CENTER
$FRAMESTATUS.TOP=$FRAMEPRINTERLIST.BOTTOM+5
$FRAMESTATUS.LEFT=302
$FRAMESTATUS.TEXT="Logon Progress:"

$LABELSTATUS=$FRAMESTATUS.LABEL("Processing logonscript...",10,20,360,20)

$PROGRESSSTATUS=$FRAMESTATUS.PROGRESSBAR
$PROGRESSSTATUS.SIZE=360,20
$PROGRESSSTATUS.CENTER
$PROGRESSSTATUS.TOP=$LABELSTATUS.BOTTOM

$FORMLOGO.SHOW
$FORMMAIN.SHOW
$PROGRESSSTATUS.MAX=UBOUND($FUNCTOEXECUTE)+3

FOR EACH $SFUNCTION IN $FUNCTOEXECUTE
   $PROGRESSSTATUS.VALUE=$PROGRESSSTATUS.VALUE+1
   $NUL=EXECUTE($SFUNCTION)
NEXT

WHILE $FORMMAIN.VISIBLE $=EXECUTE($FORMMAIN.DOEVENTS)
LOOP
EXIT()

FUNCTION COMPUTERINFO()
   $LABELSTATUS.TEXT="Checking Computer Information..."

   $OSVERSION=@PRODUCTTYPE
   
     IF VAL(@DOS)<5 $OSVERSION="UNSUPPORTED"
      EXIT
   ENDIF

   $SPVERSION=@CSD

   $LABELCOMPUTERINFOOSVERSION=$FRAMECOMPUTERINFO.LABEL("Operating System: $OSVERSION",5,20,0,20)
   $LABELCOMPUTERINFOOSVERSION.ALIGNMENT=1
   $LABELCOMPUTERINFOOSSERVICEPACK=$FRAMECOMPUTERINFO.LABEL("Service Pack: $SPVERSION",5,40,0,20)
   $LABELCOMPUTERINFOOSSERVICEPACK.ALIGNMENT=1

   $NIC=0

   :NICLOOP
      $IPGW=ENUMIPINFO($NIC,3)

      SELECT
         CASE $IPGW="192.9.0.1"      $SITEID="01"   $LOCATION="LOCATION7"      $SERVER="SERVER1"
         CASE $IPGW="192.9.1.1"      $SITEID="01"   $LOCATION="LOCATION7"      $SERVER="SERVER1"
         CASE $IPGW="192.9.2.1"      $SITEID="01"   $LOCATION="LOCATION7"      $SERVER="SERVER1"
         CASE $IPGW="192.9.10.1"      $SITEID="02"   $LOCATION="LOCATION6"      $SERVER="SERVER3"
         CASE $IPGW="192.9.20.1"      $SITEID="03"   $LOCATION="LOCATION1"      $SERVER="SERVER1"
         CASE $IPGW="192.9.30.1"      $SITEID="04"   $LOCATION="LOCATION5"      $SERVER="SERVER1"
         CASE $IPGW="192.9.32.1"      $SITEID="05"   $LOCATION="LOCATION8"      $SERVER="SERVER1"
         CASE $IPGW="192.9.35.1"      $SITEID="06"   $LOCATION="LOCATION9"      $SERVER="SERVER1"
         CASE $IPGW="192.9.36.1"      $SITEID="07"   $LOCATION="LOCATION4"      $SERVER="SERVER1"
         CASE $IPGW="192.9.40.1"      $SITEID="08"   $LOCATION="LOCATION3"      $SERVER="SERVER2"
         CASE $IPGW="192.9.50.1"      $SITEID="09"   $LOCATION="LOCATION2"      $SERVER="SERVER1"
         CASE $IPGW="192.168.0.1"   $SITEID="99"   $LOCATION="VPN - Protected"   $SERVER="SERVER1"
         CASE $IPGW="192.168.1.1"   $SITEID="99"   $LOCATION="VPN - Protected"   $SERVER="SERVER1"
         CASE 1            $SITEID="00"   $LOCATION="VPN - Unprotected"   $SERVER="SERVER1"
      ENDSELECT

      IF $SITEID = "00" AND VAL($NIC) < 10
         $NIC=VAL($NIC)+1
         GOTO NICLOOP
      ENDIF

   $IPADDRESS=ENUMIPINFO($NIC,0)

   $LABELCOMPUTERINFODHCPSTATUS=$FRAMECOMPUTERINFO.LABEL("IP Address: $IPADDRESS",5,60,0,20)
   $LABELCOMPUTERINFODHCPSTATUS.ALIGNMENT=1
   $LABELCOMPUTERINFOLOCATION=$FRAMECOMPUTERINFO.LABEL("Location: $LOCATION",5,80,0,20)
   $LABELCOMPUTERINFOLOCATION.ALIGNMENT=1
   $LABELCOMPUTERINFOSERVER=$FRAMECOMPUTERINFO.LABEL("Print Driver Location: $SERVER",5,100,0,20)
   $LABELCOMPUTERINFOSERVER.ALIGNMENT=1
ENDFUNCTION

FUNCTION PRINTERLIST()
   $BUTTONEXIT=$FORMMAIN.BUTTON
   $BUTTONEXIT.TEXT="Quit Program"
   $BUTTONEXIT.TOP=$FRAMEPRINTERACTION.BOTTOM-35
   $BUTTONEXIT.LEFT=$FRAMEPRINTERACTION.LEFT+100
   $BUTTONEXIT.SIZE=75,25
   $BUTTONEXIT.ONCLICK="Quit()"
   
   $LISTVIEWPRINTERLIST=$FORMMAIN.LISTVIEW()
   $LISTVIEWPRINTERLIST.LEFT=$FRAMEPRINTERLIST.LEFT+10
   $LISTVIEWPRINTERLIST.TOP=$FRAMEPRINTERLIST.TOP+20
   $LISTVIEWPRINTERLIST.WIDTH=0.95 * $FRAMEPRINTERLIST.CLIENTWIDTH      
   $LISTVIEWPRINTERLIST.BOTTOM=$FRAMEPRINTERLIST.BOTTOM-10
   $LISTVIEWPRINTERLIST.SORTED=1
   $LISTVIEWPRINTERLIST.SCROLLBARS=3
   
   $= $LISTVIEWPRINTERLIST.COLUMNS.ADD("Printer Name")
   
   FOR EACH $COLUMN IN $LISTVIEWPRINTERLIST.COLUMNS
      $COLUMN.WIDTH=$LISTVIEWPRINTERLIST.CLIENTWIDTH / $LISTVIEWPRINTERLIST.COLUMNS.COUNT
   NEXT

   $LISTVIEWITEMLIST=$LISTVIEWPRINTERLIST.ITEMS.ADD("LOCATION1 - ENGINEERING HP LaserJet 8150")
   $LISTVIEWITEMLIST=$LISTVIEWPRINTERLIST.ITEMS.ADD("LOCATION1 - OFFICE HP LaserJet 4050")
   $LISTVIEWITEMLIST=$LISTVIEWPRINTERLIST.ITEMS.ADD("LOCATION1 - PURCHASING HP LaserJet 4050")
   $LISTVIEWITEMLIST=$LISTVIEWPRINTERLIST.ITEMS.ADD("LOCATION1 - SHIPPING HP LaserJet 4050")
   $LISTVIEWITEMLIST=$LISTVIEWPRINTERLIST.ITEMS.ADD("LOCATION2 - ACCOUNTING HP LaserJet 4000")
   $LISTVIEWITEMLIST=$LISTVIEWPRINTERLIST.ITEMS.ADD("LOCATION2 - PLANT HP LaserJet 2100")
   $LISTVIEWITEMLIST=$LISTVIEWPRINTERLIST.ITEMS.ADD("LOCATION2 - QA HP LaserJet 4100")
   $LISTVIEWITEMLIST=$LISTVIEWPRINTERLIST.ITEMS.ADD("LOCATION2 - SHIPPING HP LaserJet 4050")
   $LISTVIEWITEMLIST=$LISTVIEWPRINTERLIST.ITEMS.ADD("LOCATION3 - ENGINEERING HP LaserJet 1100")
   $LISTVIEWITEMLIST=$LISTVIEWPRINTERLIST.ITEMS.ADD("LOCATION3 - OFFICE HP LaserJet 4050")
   $LISTVIEWITEMLIST=$LISTVIEWPRINTERLIST.ITEMS.ADD("LOCATION3 - PURCHASING HP LaserJet 4050")
   $LISTVIEWITEMLIST=$LISTVIEWPRINTERLIST.ITEMS.ADD("LOCATION3 - SHIPPING HP LaserJet 4050")
   $LISTVIEWITEMLIST=$LISTVIEWPRINTERLIST.ITEMS.ADD("LOCATION4 - OFFICE HP LaserJet 4050")
   $LISTVIEWITEMLIST=$LISTVIEWPRINTERLIST.ITEMS.ADD("LOCATION5 - ACCOUNTING HP LaserJet 4050")
   $LISTVIEWITEMLIST=$LISTVIEWPRINTERLIST.ITEMS.ADD("LOCATION5 - ENGINEERING HP LaserJet 5000")
   $LISTVIEWITEMLIST=$LISTVIEWPRINTERLIST.ITEMS.ADD("LOCATION5 - MACHINE SHOP/ENG HP LaserJet 4000")
   $LISTVIEWITEMLIST=$LISTVIEWPRINTERLIST.ITEMS.ADD("LOCATION5 - PERSONNEL HP LaserJet 4050")
   $LISTVIEWITEMLIST=$LISTVIEWPRINTERLIST.ITEMS.ADD("LOCATION5 - QC HP LaserJet 2200")
   $LISTVIEWITEMLIST=$LISTVIEWPRINTERLIST.ITEMS.ADD("LOCATION5 - SALES HP LaserJet 4000")
   $LISTVIEWITEMLIST=$LISTVIEWPRINTERLIST.ITEMS.ADD("LOCATION5 - SALES HP LaserJet 4050")
   $LISTVIEWITEMLIST=$LISTVIEWPRINTERLIST.ITEMS.ADD("LOCATION5 - SCHEDULING HP LaserJet 4000")
   $LISTVIEWITEMLIST=$LISTVIEWPRINTERLIST.ITEMS.ADD("LOCATION6 - FRONTDESK HP LaserJet 4050")
   $LISTVIEWITEMLIST=$LISTVIEWPRINTERLIST.ITEMS.ADD("LOCATION6 - OFFICE HP LaserJet 4050")
   $LISTVIEWITEMLIST=$LISTVIEWPRINTERLIST.ITEMS.ADD("LOCATION7 - ACCOUNTING HP LaserJet 4000")
   $LISTVIEWITEMLIST=$LISTVIEWPRINTERLIST.ITEMS.ADD("LOCATION7 - EXECUTIVE HP LaserJet 4050")
   $LISTVIEWITEMLIST=$LISTVIEWPRINTERLIST.ITEMS.ADD("LOCATION7 - EXECUTIVE/ENG HP LaserJet 4050")
   $LISTVIEWITEMLIST=$LISTVIEWPRINTERLIST.ITEMS.ADD("LOCATION7 - FOUNDRY HP LaserJet 5000")
   $LISTVIEWITEMLIST=$LISTVIEWPRINTERLIST.ITEMS.ADD("LOCATION7 - GUSSET HP LaserJet 5000")
   $LISTVIEWITEMLIST=$LISTVIEWPRINTERLIST.ITEMS.ADD("LOCATION7 - IT HP LaserJet 8000")
   $LISTVIEWITEMLIST=$LISTVIEWPRINTERLIST.ITEMS.ADD("LOCATION7 - MACHINE SHOP HP LaserJet 4000")
   $LISTVIEWITEMLIST=$LISTVIEWPRINTERLIST.ITEMS.ADD("LOCATION7 - PURCHASING HP LaserJet 4050")
   $LISTVIEWITEMLIST=$LISTVIEWPRINTERLIST.ITEMS.ADD("LOCATION7 - SALES HP LaserJet 4050")
   $LISTVIEWITEMLIST=$LISTVIEWPRINTERLIST.ITEMS.ADD("LOCATION7 - SHIPPING HP LaserJet 4050")
   $LISTVIEWITEMLIST=$LISTVIEWPRINTERLIST.ITEMS.ADD("LOCATION7 - WAREHOUSE HP LaserJet 4050")
   $LISTVIEWITEMLIST=$LISTVIEWPRINTERLIST.ITEMS.ADD("LOCATION8 - ENGINEERING HP LaserJet 5000")
   $LISTVIEWITEMLIST=$LISTVIEWPRINTERLIST.ITEMS.ADD("LOCATION8 - FIFTHWHEEL HP LaserJet 4100")
   $LISTVIEWITEMLIST=$LISTVIEWPRINTERLIST.ITEMS.ADD("LOCATION8 - OFFICE HP LaserJet 2100")
   $LISTVIEWITEMLIST=$LISTVIEWPRINTERLIST.ITEMS.ADD("LOCATION8 - OFFICE HP LaserJet 4050")
   $LISTVIEWITEMLIST=$LISTVIEWPRINTERLIST.ITEMS.ADD("LOCATION9 - OFFICE HP LaserJet 4000")

   $PROGRESSSTATUS.VALUE=$PROGRESSSTATUS.VALUE+2
   $LABELSTATUS.TEXT="Program Ready For Use..."
   $FRAMESTATUS.HIDE
   $FRAMESTATUS.TEXT="Printer Information:"
   $LABELSTATUS.TEXT=""
   $PROGRESSSTATUS.VISIBLE=0
   $LABELPRINTERIP=$FRAMESTATUS.LABEL("IP Address: ",5,30,0,20)
   $LABELJETDIRECT=$FRAMESTATUS.LABEL("JetDirect Model: ",205,30,0,20)
   $FRAMESTATUS.SHOW

    $LISTVIEWPRINTERLIST.SETFOCUS

   $LISTVIEWPRINTERLIST.ONCLICK="PRINTERSELECTED()"
   
   $LABELSTATUS=$FRAMEPRINTERACTION.LABEL("STATUS:",5,35,270,20)
   $LABELSTATUSTEXT=$FRAMEPRINTERACTION.LABEL("Waiting For User To Select Printer...",5,55,270,20)
   $LABELSTATUSTEXT.FORECOLOR=Blue
ENDFUNCTION

FUNCTION PRINTERSELECTED()
   
   IF $LISTVIEWPRINTERLIST.FOCUSEDITEM.SELECTED
      $CURRENTPRINTER=$LISTVIEWPRINTERLIST.FOCUSEDITEM.SUBITEMS(0).TEXT
      
      SELECT
         CASE $CURRENTPRINTER="LOCATION1 - ENGINEERING HP DesignJet 1055"   $PRINTERIP="192.9.220.47"   $JETDIRECT="J3113A"   $DRIVERPATH="HP DesignJet 1055 For 2000 & XP\OEMSETUP.INF"   $REALNAME="HP DesignJet 1055CM by HP"
         CASE $CURRENTPRINTER="LOCATION1 - ENGINEERING HP LaserJet 8150"      $PRINTERIP="192.9.220.48"   $JETDIRECT="J4169A"   $DRIVERPATH="HP LaserJet 8150 For 2000 & XP\HP8150_6.INF"   $REALNAME="HP LaserJet 8150 PCL 6"
         CASE $CURRENTPRINTER="LOCATION1 - OFFICE HP Color LaserJet 5500"   $PRINTERIP="192.9.220.49"   $JETDIRECT="J6057A"   $DRIVERPATH="HP Color LaserJet 5500 For 2000 & XP\HP5500P6.INF"   $REALNAME="HP Color LaserJet 5500 PCL6"
         CASE $CURRENTPRINTER="LOCATION1 - OFFICE HP LaserJet 4050"      $PRINTERIP="192.9.220.42"   $JETDIRECT="J3113A"   $DRIVERPATH="HP LaserJet 4050 For 2000 & XP\HP002IP6.INF"   $REALNAME="HP LaserJet 4050 Series PCL 6"
         CASE $CURRENTPRINTER="LOCATION1 - PURCHASING HP LaserJet 4050"      $PRINTERIP="192.9.220.41"   $JETDIRECT="J3113A"   $DRIVERPATH="HP LaserJet 4050 For 2000 & XP\HP002IP6.INF"   $REALNAME="HP LaserJet 4050 Series PCL 6"
         CASE $CURRENTPRINTER="LOCATION1 - QA HP LaserJet 4V"         $PRINTERIP="192.9.220.46"   $JETDIRECT="J4100A"   $DRIVERPATH="HP LaserJet 4 - 5 - 6 For 2000 & XP\LJ456P5.INF"   $REALNAME="HP LaserJet 4V"
         CASE $CURRENTPRINTER="LOCATION1 - SALES HP LaserJet 4 Plus"      $PRINTERIP="192.9.220.44"   $JETDIRECT="J4100A"   $DRIVERPATH="HP LaserJet 4 - 5 - 6 For 2000 & XP\LJ456P5.INF"   $REALNAME="HP LaserJet 4 Plus"
         CASE $CURRENTPRINTER="LOCATION1 - SHIPPING HP LaserJet 4050"      $PRINTERIP="192.9.220.43"   $JETDIRECT="J3113A"   $DRIVERPATH="HP LaserJet 4050 For 2000 & XP\HP002IP6.INF"   $REALNAME="HP LaserJet 4050 Series PCL 6"
         CASE $CURRENTPRINTER="LOCATION2 - ACCOUNTING HP LaserJet 4000"      $PRINTERIP="192.9.250.34"   $JETDIRECT="J3111A"   $DRIVERPATH="HP LaserJet 4000 For 2000 & XP\HP222IP6.INF"   $REALNAME="HP LaserJet 4000 Series PCL 6"
         CASE $CURRENTPRINTER="LOCATION2 - ENGINEERING HP DesignJet 450"      $PRINTERIP="192.9.250.43"   $JETDIRECT="J4101B"   $DRIVERPATH="HP DesignJet 450 For 2000 & XP\OEMSETUP.INF"   $REALNAME="HP DesignJet 450C (E/A0) by HP"
         CASE $CURRENTPRINTER="LOCATION2 - HR HP LaserJet 6L"         $PRINTERIP="192.9.250.44"   $JETDIRECT="J4101B"   $DRIVERPATH="HP LaserJet 4 - 5 - 6 For 2000 & XP\LJ456P5.INF"   $REALNAME="HP LaserJet 6L"
         CASE $CURRENTPRINTER="LOCATION2 - OFFICE HP Color LaserJet 5M"      $PRINTERIP="192.9.250.46"   $JETDIRECT="J4100A"                           $REALNAME="HP Color LaserJet 5M"
         CASE $CURRENTPRINTER="LOCATION2 - PLANT HP LaserJet 2100"      $PRINTERIP="192.9.250.47"   $JETDIRECT="J3110A"   $DRIVERPATH="HP LaserJet 2100 For 2000 & XP\HP212IP6.INF"   $REALNAME="HP LaserJet 2100 Series PCL 6"
         CASE $CURRENTPRINTER="LOCATION2 - PURCHASING HP LaserJet 4050"      $PRINTERIP="192.9.250.41"   $JETDIRECT="J3113A"   $DRIVERPATH="HP LaserJet 4050 For 2000 & XP\HP002IP6.INF"   $REALNAME="HP LaserJet 4050 Series PCL 6"
         CASE $CURRENTPRINTER="LOCATION2 - QA HP LaserJet 4"         $PRINTERIP="192.9.250.45"   $JETDIRECT="J4100A"   $DRIVERPATH="HP LaserJet 4 - 5 - 6 For 2000 & XP\LJ456P5.INF"   $REALNAME="HP LaserJet 4"
         CASE $CURRENTPRINTER="LOCATION2 - QA HP LaserJet 4100"         $PRINTERIP="192.9.250.48"   $JETDIRECT="J4169A"   $DRIVERPATH="HP LaserJet 4100 For 2000 & XP\HP4100P6.INF"   $REALNAME="HP LaserJet 4100 PCL 6"
         CASE $CURRENTPRINTER="LOCATION2 - SHIPPING HP LaserJet 4050"      $PRINTERIP="192.9.250.42"   $JETDIRECT="J3113A"   $DRIVERPATH="HP LaserJet 4050 For 2000 & XP\HP002IP6.INF"   $REALNAME="HP LaserJet 4050 Series PCL 6"   
         CASE $CURRENTPRINTER="LOCATION3 - ENGINEERING HP DesignJet 600"      $PRINTERIP="192.9.240.51"   $JETDIRECT="J4101B"   $DRIVERPATH="HP DesignJet 600 For 2000 & XP\OEMSETUP.INF"   $REALNAME="HP DesignJet 600 (E/A0) by HP"
         CASE $CURRENTPRINTER="LOCATION3 - ENGINEERING HP LaserJet 5"      $PRINTERIP="192.9.240.29"   $JETDIRECT="J4100A"   $DRIVERPATH="HP LaserJet 4 - 5 - 6 For 2000 & XP\LJ456P5.INF"   $REALNAME="HP LaserJet 5Si"
         CASE $CURRENTPRINTER="LOCATION3 - ENGINEERING HP LaserJet 1100"      $PRINTERIP="192.9.240.45"   $JETDIRECT="J4101B"   $DRIVERPATH="HP LaserJet 1100 For 2000 & XP\HP201IP5.INF"   $REALNAME="HP LaserJet 1100"
         CASE $CURRENTPRINTER="LOCATION3 - OFFICE HP LaserJet 4050"      $PRINTERIP="192.9.240.31"   $JETDIRECT="J3113A"   $DRIVERPATH="HP LaserJet 4050 For 2000 & XP\HP002IP6.INF"   $REALNAME="HP LaserJet 4050 Series PCL 6"
         CASE $CURRENTPRINTER="LOCATION3 - PURCHASING HP LaserJet 4050"      $PRINTERIP="192.9.240.32"   $JETDIRECT="J3113A"   $DRIVERPATH="HP LaserJet 4050 For 2000 & XP\HP002IP6.INF"   $REALNAME="HP LaserJet 4050 Series PCL 6"
         CASE $CURRENTPRINTER="LOCATION3 - QA HP LaserJet 1200"         $PRINTERIP="192.9.240.48"   $JETDIRECT="J4101B"   $DRIVERPATH="HP LaserJet 1200 For 2000 & XP\HPBF312I.INF"   $REALNAME="HP LaserJet 1200"
         CASE $CURRENTPRINTER="LOCATION3 - SHIPPING HP LaserJet 4050"      $PRINTERIP="192.9.240.33"   $JETDIRECT="J3113A"   $DRIVERPATH="HP LaserJet 4050 For 2000 & XP\HP002IP6.INF"   $REALNAME="HP LaserJet 4050 Series PCL 6"
         CASE $CURRENTPRINTER="LOCATION4 - OFFICE HP Color LaserJet 4500"   $PRINTERIP="192.9.236.42"   $JETDIRECT="J4100A"   $DRIVERPATH="HP Color LaserJet 4500 For 2000 & XP\HP232IP6.INF"   $REALNAME="HP Color LaserJet 4500 PCL 6"
         CASE $CURRENTPRINTER="LOCATION4 - OFFICE HP LaserJet 4050"      $PRINTERIP="192.9.236.41"   $JETDIRECT="J4100A"   $DRIVERPATH="HP LaserJet 4050 For 2000 & XP\HP002IP6.INF"   $REALNAME="HP LaserJet 4050 Series PCL 6"
         CASE $CURRENTPRINTER="LOCATION5 - ACCOUNTING HP LaserJet 4"      $PRINTERIP="192.9.230.45"   $JETDIRECT="J4100A"   $DRIVERPATH="HP LaserJet 4 - 5 - 6 For 2000 & XP\LJ456P5.INF"   $REALNAME="HP LaserJet 4"
         CASE $CURRENTPRINTER="LOCATION5 - ACCOUNTING HP LaserJet 4050"      $PRINTERIP="192.9.230.42"   $JETDIRECT="J3113A"   $DRIVERPATH="HP LaserJet 4050 For 2000 & XP\HP002IP6.INF"   $REALNAME="HP LaserJet 4050 Series PCL 6"
         CASE $CURRENTPRINTER="LOCATION5 - ENGINEERING HP DesignJet 750"      $PRINTERIP="192.9.230.51"   $JETDIRECT="J4100A"   $DRIVERPATH="HP DesignJet 750 For 2000 & XP\OEMSETUP.INF"   $REALNAME="HP DesignJet 750C (E/A0) by HP"
         CASE $CURRENTPRINTER="LOCATION5 - ENGINEERING HP LaserJet 5000"      $PRINTERIP="192.9.230.59"   $JETDIRECT="J3111A"   $DRIVERPATH="HP LaserJet 5000 For 2000 & XP\HP242IP6.INF"   $REALNAME="HP LaserJet 5000 Series PCL 6"
         CASE $CURRENTPRINTER="LOCATION5 - FOUNDRY HP LaserJet 4 Plus"      $PRINTERIP="192.9.230.48"   $JETDIRECT="J4100A"   $DRIVERPATH="HP LaserJet 4 - 5 - 6 For 2000 & XP\LJ456P5.INF"   $REALNAME="HP LaserJet 4 Plus"
         CASE $CURRENTPRINTER="LOCATION5 - IT HP LaserJet 4 Plus"      $PRINTERIP="192.9.230.46"   $JETDIRECT="J4100A"   $DRIVERPATH="HP LaserJet 4 - 5 - 6 For 2000 & XP\LJ456P5.INF"   $REALNAME="HP LaserJet 4 Plus"
         CASE $CURRENTPRINTER="LOCATION5 - MACHINE SHOP/ENG HP LaserJet 4000"   $PRINTERIP="192.9.230.54"   $JETDIRECT="J3111A"   $DRIVERPATH="HP LaserJet 4000 For 2000 & XP\HP222IP6.INF"   $REALNAME="HP LaserJet 4000 Series PCL 6"
         CASE $CURRENTPRINTER="LOCATION5 - OFFICE HP Color LaserJet 4500"   $PRINTERIP="192.9.230.47"   $JETDIRECT="J3113A"   $DRIVERPATH="HP Color LaserJet 4500 For 2000 & XP\HP232IP6.INF"   $REALNAME="HP Color LaserJet 4500 PCL 6"   
         CASE $CURRENTPRINTER="LOCATION5 - PERSONNEL HP LaserJet 4050"      $PRINTERIP="192.9.230.44"   $JETDIRECT="J3113A"   $DRIVERPATH="HP LaserJet 4050 For 2000 & XP\HP002IP6.INF"   $REALNAME="HP LaserJet 4050 Series PCL 6"
         CASE $CURRENTPRINTER="LOCATION5 - PURCHASING HP LaserJet 4"      $PRINTERIP="192.9.230.49"   $JETDIRECT="J4100A"   $DRIVERPATH="HP LaserJet 4 - 5 - 6 For 2000 & XP\LJ456P5.INF"   $REALNAME="HP LaserJet 4"
         CASE $CURRENTPRINTER="LOCATION5 - PURCHASING HP LaserJet 4 Plus"   $PRINTERIP="192.9.230.41"   $JETDIRECT="J4100A"   $DRIVERPATH="HP LaserJet 4 - 5 - 6 For 2000 & XP\LJ456P5.INF"   $REALNAME="HP LaserJet 4 Plus"
         CASE $CURRENTPRINTER="LOCATION5 - QC HP LaserJet 2200"         $PRINTERIP="192.9.230.62"   $JETDIRECT="J4169A"   $DRIVERPATH="HP LaserJet 2200 For 2000 & XP\HPBF322I.INF"   $REALNAME="HP LaserJet 2200 Series PCL 6"
         CASE $CURRENTPRINTER="LOCATION5 - SALES HP LaserJet 4000"      $PRINTERIP="192.9.230.56"   $JETDIRECT="J3111A"   $DRIVERPATH="HP LaserJet 4000 For 2000 & XP\HP222IP6.INF"   $REALNAME="HP LaserJet 4000 Series PCL 6"
         CASE $CURRENTPRINTER="LOCATION5 - SALES HP LaserJet 4050"      $PRINTERIP="192.9.230.43"   $JETDIRECT="J3113A"   $DRIVERPATH="HP LaserJet 4050 For 2000 & XP\HP002IP6.INF"   $REALNAME="HP LaserJet 4050 Series PCL 6"
         CASE $CURRENTPRINTER="LOCATION5 - SCHEDULING HP LaserJet 4000"      $PRINTERIP="192.9.230.55"   $JETDIRECT="J3111A"   $DRIVERPATH="HP LaserJet 4000 For 2000 & XP\HP222IP6.INF"   $REALNAME="HP LaserJet 4000 Series PCL 6"
         CASE $CURRENTPRINTER="LOCATION6 - FRONTDESK HP LaserJet 4050"      $PRINTERIP="192.9.210.42"   $JETDIRECT="J3113A"   $DRIVERPATH="HP LaserJet 4050 For 2000 & XP\HP002IP6.INF"   $REALNAME="HP LaserJet 4050 Series PCL 6"
         CASE $CURRENTPRINTER="LOCATION6 - OFFICE HP DesignJet 650"      $PRINTERIP="192.9.210.43"   $JETDIRECT="J4100A"   $DRIVERPATH="HP DesignJet 650 For 2000 & XP\OEMSETUP.INF"   $REALNAME="HP DesignJet 650C(C2859B) by HP"
         CASE $CURRENTPRINTER="LOCATION6 - OFFICE HP LaserJet 4050"      $PRINTERIP="192.9.210.41"   $JETDIRECT="J3113A"   $DRIVERPATH="HP LaserJet 4050 For 2000 & XP\HP002IP6.INF"   $REALNAME="HP LaserJet 4050 Series PCL 6"
         CASE $CURRENTPRINTER="LOCATION7 - ACCOUNTING HP LaserJet 4"      $PRINTERIP="192.9.200.56"   $JETDIRECT="J4100A"   $DRIVERPATH="HP LaserJet 4 - 5 - 6 For 2000 & XP\LJ456P5.INF"   $REALNAME="HP LaserJet 4"
         CASE $CURRENTPRINTER="LOCATION7 - ACCOUNTING HP LaserJet 4000"      $PRINTERIP="192.9.200.31"   $JETDIRECT="J3111A"   $DRIVERPATH="HP LaserJet 4000 For 2000 & XP\HP222IP6.INF"   $REALNAME="HP LaserJet 4000 Series PCL 6"
         CASE $CURRENTPRINTER="LOCATION7 - ACCOUNTING HP LaserJet 8100"      $PRINTERIP="192.9.200.85"   $JETDIRECT="J3113A"   $DRIVERPATH="HP LaserJet 8100 For 2000 & XP\HP014IP6.INF"   $REALNAME="HP LaserJet 8100 Series PCL 6"
         CASE $CURRENTPRINTER="LOCATION7 - ENGINEERING HP LaserJet 4 Plus"   $PRINTERIP="192.9.200.34"   $JETDIRECT="J4100A"   $DRIVERPATH="HP LaserJet 4 - 5 - 6 For 2000 & XP\LJ456P5.INF"   $REALNAME="HP LaserJet 4 Plus"
         CASE $CURRENTPRINTER="LOCATION7 - ENGINEERING HP LaserJet 5Si"      $PRINTERIP="192.9.200.41"   $JETDIRECT="J4100A"   $DRIVERPATH="HP LaserJet 4 - 5 - 6 For 2000 & XP\LJ456P5.INF"   $REALNAME="HP LaserJet 5Si"
         CASE $CURRENTPRINTER="LOCATION7 - EXECUTIVE HP LaserJet 4050"      $PRINTERIP="192.9.200.53"   $JETDIRECT="J3113A"   $DRIVERPATH="HP LaserJet 4050 For 2000 & XP\HP002IP6.INF"   $REALNAME="HP LaserJet 4050 Series PCL 6"
         CASE $CURRENTPRINTER="LOCATION7 - EXECUTIVE/ENG HP LaserJet 4050"   $PRINTERIP="192.9.200.33"   $JETDIRECT="J3113A"   $DRIVERPATH="HP LaserJet 4050 For 2000 & XP\HP002IP6.INF"   $REALNAME="HP LaserJet 4050 Series PCL 6"
         CASE $CURRENTPRINTER="LOCATION7 - FOUNDRY HP LaserJet 4"      $PRINTERIP="192.9.200.42"   $JETDIRECT="J3263A"   $DRIVERPATH="HP LaserJet 4 - 5 - 6 For 2000 & XP\LJ456P5.INF"   $REALNAME="HP LaserJet 4"
         CASE $CURRENTPRINTER="LOCATION7 - FOUNDRY HP LaserJet 4"      $PRINTERIP="192.9.200.81"   $JETDIRECT="J4100A"   $DRIVERPATH="HP LaserJet 4 - 5 - 6 For 2000 & XP\LJ456P5.INF"   $REALNAME="HP LaserJet 4"
         CASE $CURRENTPRINTER="LOCATION7 - FOUNDRY HP LaserJet 5000"      $PRINTERIP="192.9.200.89"   $JETDIRECT="J3111A"   $DRIVERPATH="HP LaserJet 5000 For 2000 & XP\HP242IP6.INF"   $REALNAME="HP LaserJet 5000 Series PCL 6"
         CASE $CURRENTPRINTER="LOCATION7 - GUSSET HP LaserJet 5000"      $PRINTERIP="192.9.200.93"   $JETDIRECT="J3111A"   $DRIVERPATH="HP LaserJet 5000 For 2000 & XP\HP242IP6.INF"   $REALNAME="HP LaserJet 5000 Series PCL 6"
         CASE $CURRENTPRINTER="LOCATION7 - GUSSET HP LaserJet 6P"      $PRINTERIP="192.9.200.90"   $JETDIRECT="J4101A"   $DRIVERPATH="HP LaserJet 4 - 5 - 6 For 2000 & XP\LJ456P5.INF"   $REALNAME="HP LaserJet 6P"
         CASE $CURRENTPRINTER="LOCATION7 - HR HP LaserJet 4"         $PRINTERIP="192.9.200.43"   $JETDIRECT="J4100A"   $DRIVERPATH="HP LaserJet 4 - 5 - 6 For 2000 & XP\LJ456P5.INF"   $REALNAME="HP LaserJet 4"
         CASE $CURRENTPRINTER="LOCATION7 - IT HP LaserJet 5Si"         $PRINTERIP="192.9.200.51"   $JETDIRECT="J4100A"   $DRIVERPATH="HP LaserJet 4 - 5 - 6 For 2000 & XP\LJ456P5.INF"   $REALNAME="HP LaserJet 5Si"
         CASE $CURRENTPRINTER="LOCATION7 - IT HP LaserJet 8000"         $PRINTERIP="192.9.200.52"   $JETDIRECT="J3113A"   $DRIVERPATH="HP LaserJet 8000 For 2000 & XP\HP022IP6.INF"   $REALNAME="HP LaserJet 8000 Series PCL 6"
         CASE $CURRENTPRINTER="LOCATION7 - MACHINE SHOP HP LaserJet III"      $PRINTERIP="192.9.200.95"   $JETDIRECT="J4101B"                           $REALNAME="HP LaserJet III"
         CASE $CURRENTPRINTER="LOCATION7 - MACHINE SHOP HP LaserJet 4"      $PRINTERIP="192.9.200.92"   $JETDIRECT="J4100A"   $DRIVERPATH="HP LaserJet 4 - 5 - 6 For 2000 & XP\LJ456P5.INF"   $REALNAME="HP LaserJet 4"
         CASE $CURRENTPRINTER="LOCATION7 - MACHINE SHOP HP LaserJet 4000"   $PRINTERIP="192.9.200.99"   $JETDIRECT="J3111A"   $DRIVERPATH="HP LaserJet 4000 For 2000 & XP\HP222IP6.INF"   $REALNAME="HP LaserJet 4000 Series PCL 6"
         CASE $CURRENTPRINTER="LOCATION7 - OFFICE HP LaserJet 4 Plus"      $PRINTERIP="192.9.200.44"   $JETDIRECT="J4100A"   $DRIVERPATH="HP LaserJet 4 - 5 - 6 For 2000 & XP\LJ456P5.INF"   $REALNAME="HP LaserJet 4 Plus"
         CASE $CURRENTPRINTER="LOCATION7 - PAYROLL HP LaserJet 4 Plus"      $PRINTERIP="192.9.200.32"   $JETDIRECT="J4100A"   $DRIVERPATH="HP LaserJet 4 - 5 - 6 For 2000 & XP\LJ456P5.INF"   $REALNAME="HP LaserJet 4 Plus"
         CASE $CURRENTPRINTER="LOCATION7 - PURCHASING HP LaserJet 4L"      $PRINTERIP="192.9.200.47"   $JETDIRECT="J4102A"   $DRIVERPATH="HP LaserJet 4 - 5 - 6 For 2000 & XP\LJ456P5.INF"   $REALNAME="HP LaserJet 4L"
         CASE $CURRENTPRINTER="LOCATION7 - PURCHASING HP LaserJet 4050"      $PRINTERIP="192.9.200.86"   $JETDIRECT="J3113A"   $DRIVERPATH="HP LaserJet 4050 For 2000 & XP\HP002IP6.INF"   $REALNAME="HP LaserJet 4050 Series PCL 6"
         CASE $CURRENTPRINTER="LOCATION7 - SALES HP LaserJet 4050"      $PRINTERIP="192.9.200.77"   $JETDIRECT="J3113A"   $DRIVERPATH="HP LaserJet 4050 For 2000 & XP\HP002IP6.INF"   $REALNAME="HP LaserJet 4050 Series PCL 6"
         CASE $CURRENTPRINTER="LOCATION7 - SHIPPING HP LaserJet 4050"      $PRINTERIP="192.9.200.67"   $JETDIRECT="J4100A"   $DRIVERPATH="HP LaserJet 4050 For 2000 & XP\HP002IP6.INF"   $REALNAME="HP LaserJet 4050 Series PCL 6"
         CASE $CURRENTPRINTER="LOCATION7 - WAREHOUSE HP LaserJet 4050"      $PRINTERIP="192.9.200.76"   $JETDIRECT="J3113A"   $DRIVERPATH="HP LaserJet 4050 For 2000 & XP\HP002IP6.INF"   $REALNAME="HP LaserJet 4050 Series PCL 6"
         CASE $CURRENTPRINTER="LOCATION8 - ENGINEERING HP LaserJet 5000"      $PRINTERIP="192.9.232.44"   $JETDIRECT="J4169A"   $DRIVERPATH="HP LaserJet 5000 For 2000 & XP\HP242IP6.INF"   $REALNAME="HP LaserJet 5000 Series PCL 6"
         CASE $CURRENTPRINTER="LOCATION8 - FIFTHWHEEL HP LaserJet 4 Plus"   $PRINTERIP="192.9.232.47"   $JETDIRECT="J4100A"   $DRIVERPATH="HP LaserJet 4 - 5 - 6 For 2000 & XP\LJ456P5.INF"   $REALNAME="HP LaserJet 4 Plus"
         CASE $CURRENTPRINTER="LOCATION8 - FIFTHWHEEL HP LaserJet 4100"      $PRINTERIP="192.9.232.49"   $JETDIRECT="J4169A"   $DRIVERPATH="HP LaserJet 4100 For 2000 & XP\HP4100P6.INF"   $REALNAME="HP LaserJet 4100 PCL 6"
         CASE $CURRENTPRINTER="LOCATION8 - OFFICE HP LaserJet 2100"      $PRINTERIP="192.9.232.42"   $JETDIRECT="J4101B"   $DRIVERPATH="HP LaserJet 2100 For 2000 & XP\HP212IP6.INF"   $REALNAME="HP LaserJet 2100 Series PCL 6"
         CASE $CURRENTPRINTER="LOCATION8 - OFFICE HP LaserJet 4050"      $PRINTERIP="192.9.232.41"   $JETDIRECT="J3113A"   $DRIVERPATH="HP LaserJet 4050 For 2000 & XP\HP002IP6.INF"   $REALNAME="HP LaserJet 4050 Series PCL 6"
         CASE $CURRENTPRINTER="LOCATION8 - PURCHASING HP LaserJet 6L"      $PRINTERIP="192.9.232.45"   $JETDIRECT="J4101B"   $DRIVERPATH="HP LaserJet 4 - 5 - 6 For 2000 & XP\LJ456P5.INF"   $REALNAME="HP LaserJet 6L"
         CASE $CURRENTPRINTER="LOCATION8 - QC HP LaserJet 4V"         $PRINTERIP="192.9.232.43"   $JETDIRECT="J4100A"   $DRIVERPATH="HP LaserJet 4 - 5 - 6 For 2000 & XP\LJ456P5.INF"   $REALNAME="HP LaserJet 4V"
         CASE $CURRENTPRINTER="LOCATION8 - WAREHOUSE HP LaserJet 5"      $PRINTERIP="192.9.232.48"   $JETDIRECT="J4100A"   $DRIVERPATH="HP LaserJet 4 - 5 - 6 For 2000 & XP\LJ456P5.INF"   $REALNAME="HP LaserJet 5"
         CASE $CURRENTPRINTER="LOCATION9 - OFFICE HP LaserJet 4000"      $PRINTERIP="192.9.235.41"   $JETDIRECT="J3111A"   $DRIVERPATH="HP LaserJet 4000 For 2000 & XP\HP222IP6.INF"   $REALNAME="HP LaserJet 4000 Series PCL 6"
         CASE 1                           $PRINTERIP=""         $JETDIRECT=""
      ENDSELECT

      $PRINTERIPADDRESS=$FRAMESTATUS.LABEL("IP Address: $PRINTERIP",5,20,0,20)
      $JETDIRECTMODEL=$FRAMESTATUS.LABEL("JetDirect Model: $JETDIRECT",205,20,0,20)
   ENDIF
   
   IF $DRIVERPATH=""
      $INSTALLLOCATION=""
   ELSE   
      $INSTALLLOCATION="\\"+$SERVER+"\SOFTWARE\DRIVERS\PRINTERS\"+$DRIVERPATH
   ENDIF

   $=ADDPRINTER($PRINTERIP,$REALNAME,$INSTALLLOCATION,$CURRENTPRINTER,,0)

   RETURN

ENDFUNCTION

FUNCTION ADDPRINTER($PORT,$PRINTERTYPE,OPTIONAL $DRIVERINF,OPTIONAL $PRINTERDESC,OPTIONAL $REMOTEPC,OPTIONAL $DEFAULT)
   DIM $PORT,$PRINTERTYPE,$DRIVERINF,$PRINTERDESC,$REMOTEPC,$DEFAULT,$QUITLOOP,$IPPRINTERKEY
 
   $FORMMAIN.MOUSEPOINTER=11
                $LABELSTATUSTEXT=$FRAMEPRINTERACTION.LABEL("Installing Printer...PLEASE WAIT!",5,55,270,20)
   $LABELSTATUSTEXT.FORECOLOR=Red
   
   $ADDPRINTER=0
 
   IF NOT LEFT($PORT,2)="\\"
      IF $DRIVERINF=""
               $DRIVERINF="%WINDIR%\INF\NTPRINT.INF"
      ENDIF
      
      IF NOT EXIST($DRIVERINF)
         EXIT -3
      ENDIF
      
      SHELL '%COMSPEC% /C TYPE "$DRIVERINF">%TEMP%\ADDPRINTER.TXT'

      IF OPEN(3,"%TEMP%\ADDPRINTER.TXT",0)=0
         $QUITLOOP=0

         WHILE @ERROR=0 AND $QUITLOOP=0
            $LINE=READLINE(3)
            $QUITLOOP=INSTR($LINE,$PRINTERTYPE)
         LOOP

         $=CLOSE(3)

         IF $QUITLOOP=0
            EXIT -2
         ENDIF
      ELSE
         EXIT -3
      ENDIF
   ENDIF

   IF $PRINTERDESC=""
      $PRINTERDESC=$PRINTERTYPE
   ENDIF

   IF $REMOTEPC=""
      $REMOTEPC='\\'+ @WKSTA
   ELSE
      IF NOT LEFT($REMOTEPC,2)="\\"
         $REMOTEPC='\\' + $REMOTEPC
      ENDIF
     ENDIF

   SELECT
          CASE LEFT($PORT,2)="\\"
         $PRINTSERVER=1
         $PRINTERDESC=$PORT
      CASE INSTR($PORT,".")
         $IPPRINTERKEY='$REMOTEPC\HKEY_LOCAL_MACHINE\SYSTEM\CURRENTCONTROLSET\CONTROL\PRINT\MONITORS\STANDARD TCP/IP PORT\PORTS\IP_' +$PORT

         IF KEYEXIST($IPPRINTERKEY)
            $=DELTREE($IPPRINTERKEY)
         ENDIF

         IF NOT KEYEXIST($IPPRINTERKEY)
                 $=ADDKEY($IPPRINTKEY)
                 $=WRITEVALUE($IPPRINTERKEY,"Double Spool","00000001","REG_DWORD")
            $=WRITEVALUE($IPPRINTERKEY,"HostName","", "REG_SZ")
            $=WRITEVALUE($IPPRINTERKEY,"HWAddress","","REG_SZ")
            $=WRITEVALUE($IPPRINTERKEY,"IPAddress","$PORT","REG_SZ")
            $=WRITEVALUE($IPPRINTERKEY,"PortNumber","00000515","REG_DWORD")
                 $=WRITEVALUE($IPPRINTERKEY,"Protocol","00000002","REG_DWORD")
            $=WRITEVALUE($IPPRINTERKEY,"Queue","RAW","REG_SZ")
            $=WRITEVALUE($IPPRINTERKEY,"SNMP Community","public","REG_SZ")
                 $=WRITEVALUE($IPPRINTERKEY,"SNMP Enabled","00000000","REG_DWORD")
                 $=WRITEVALUE($IPPRINTERKEY,"SNMP Index","00000001","REG_DWORD")
                 $=WRITEVALUE($IPPRINTERKEY,"VERSION","00000001","REG_DWORD")
         ENDIF

         $OBJECTS=GETOBJECT("WINMGMTS:{IMPERSONATIONLEVEL=IMPERSONATE}!"+$REMOTEPC+"\ROOT\CIMV2")

         IF NOT @ERROR=0
            EXIT -4
         ENDIF

         $SERVICES=$OBJECTS.EXECQUERY('Select * from Win32_Service WHERE Name = "Spooler"')
               
         FOR EACH $SPOOLER IN $SERVICES
            $=EXECUTE('$$=$$SPOOLER.STOPSERVICE()')
         NEXT
          
         SLEEP 1

         FOR EACH $SPOOLER IN $SERVICES
                 $=EXECUTE('$$=$$SPOOLER.STARTSERVICE()')
         NEXT

         $PORT='IP_$PORT'

      CASE UCASE(LEFT($PORT,3))="LPT" OR UCASE(LEFT($PORT,3))="COM"
         IF NOT RIGHT($PORT,1)=":"
                 $PORT=$PORT+":"
         ENDIF

         IF NOT VAL(LEFT(RIGHT($PORT,2),1))>=1
            EXIT -1
         ENDIF

      CASE UCASE(LEFT($PORT,4))="FILE"
         IF NOT RIGHT($PORT,1)=":"
            $PORT=$PORT+":"
         ENDIF

      CASE 1
         EXIT -1
   ENDSELECT

   IF NOT $PRINTSERVER=1
      SHELL 'RUNDLL32 PRINTUI.DLL,PrintUIEntry /if /b "$PRINTERDESC" /c "$REMOTEPC" /f "$DRIVERINF" /r "$PORT" /m "$PRINTERTYPE" /z /u '
   ELSE
      IF NOT ADDPRINTERCONNECTION($PORT)=0
         EXIT @ERROR
      ENDIF
   ENDIF

   IF $DEFAULT=1
      IF NOT SETDEFAULTPRINTER($PRINTERDESC)=0
         EXIT @ERROR
      ENDIF
   ENDIF

   $ADDPRINTER=1

   $LABELSTATUSTEXT=$FRAMEPRINTERACTION.LABEL("Finishing Installing Printer - Select Another Printer Or Quit",5,55,270,20)
   $LABELSTATUSTEXT.FORECOLOR=Blue
                $FORMMAIN.MOUSEPOINTER=0
ENDFUNCTION


Last edited by agconmet on Wed May 21, 2003 10:58 pm; edited 2 times in total
Back to top
View user's profile Send private message
Chris S.
KiXforms Enthusiast
KiXforms Enthusiast


Joined: 05 Mar 2003
Posts: 241

PostPosted: Thu May 15, 2003 1:37 am    Post subject: Reply with quote

Hey, the first part of that script looks vaguely familar. Wink Very Happy
Back to top
View user's profile Send private message MSN Messenger
Sealeopard
KiXforms Aficionado
KiXforms Aficionado


Joined: 05 Mar 2003
Posts: 436
Location: Boston, MA

PostPosted: Thu May 15, 2003 1:29 pm    Post subject: Reply with quote

This
Code:
SELECT
          CASE $OS="Windows 2000 Professional"      $OSVERSION="Windows 2000 Professional"
          CASE $OS="Windows 2000 Server"         $OSVERSION="Windows 2000 Server"
          CASE $OS="Windows 2000 Domain Controller"   $OSVERSION="Windows 2000 Domain Controller"
          CASE $OS="Windows XP Home Edition"      $OSVERSION="Windows XP Home Edition"
          CASE $OS="Windows XP Professional"      $OSVERSION="Windows XP Professional"
          CASE $OS="Windows 2003 Server"         $OSVERSION="Windows 2003 Server"
          CASE $OS="Windows 2003 Domain Controller"   $OSVERSION="Windows 2003 Domain Controller"
          CASE 1                        $OSVERSION="UNSUPPORTED"
   ENDSELECT
is not necessary, just os a $OSVERSION=$OS or even simpler as in
Code:
if  val(@DOS)<5 $OSVERSION="UNSUPPORTED" ENDIF
.

Second;y, put all the printers into an .INI file and read them dynamically. this way, it's easier to add/remove printers. You could also automatically enumerate printers on the various print servers.

Also, the KIXFORMS.DLL should be installed into %WINDIR%\SYSTEM32. It will also require at least Power Users rights, there's no rights check.

Frames should no longer be used in the latest release of KiXforms as support might be dropped in a later version, the replacement is the GroupBox.

Code:
   ? "AP PORT: " $PORT
Why do you print stuff to the console if you'rer developing a KiXforms application?


The whole application seems to require domain administrative rights due to the remote computer registry access.

_________________
Jens

'There are two kinds of vessels, submarines and targets.'
Back to top
View user's profile Send private message Send e-mail MSN Messenger
agconmet
KiXforms Follower
KiXforms Follower


Joined: 12 May 2003
Posts: 15

PostPosted: Thu May 15, 2003 3:19 pm    Post subject: Reply with quote

Chris S.,

I did borrow the theme from Lonkero's sample login script or maybe it was yours...it was a while back...

Sealeopard,

First off, thanks for the suggestions...

I was not sure about the INI file so that is why everything is in the file itself.

Our login script already creates a C:\NETWORK folder and puts the KIXFORMS.DLL in there, so I just using what is all ready there.

Is there any documentation on GroupBox?

The console stuff ? "AP PORT: " $PORT was for debugging purposes and I should have removed it.

The remote computer registry access was build into the ADDPRINTER() function; however, my script does not make use of it. The only rights necessary are the rights to register the KIXFORMS.DLL if it is not all ready registered (most of our users all ready are registered).
Back to top
View user's profile Send private message
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Thu May 15, 2003 3:39 pm    Post subject: Reply with quote

The GroupBox control will be replacing the Frame control in the long-term, problem is - it is only available in the latest Beta. In the short-term I would suggest "preparing" for the GroupBox and you do that my ensuring that all your controls (that are embedded inside frames and subsequently GroupBoxes) are created as "children of the frame". Since groupbox will be non-transparent, if there are controls on the form, but behind the GroupBox, your controls will be hidden from view. If you do this, then it should just be a matter of doing a string replace from Frame->GroupBox.
Back to top
View user's profile Send private message
Chris S.
KiXforms Enthusiast
KiXforms Enthusiast


Joined: 05 Mar 2003
Posts: 241

PostPosted: Thu May 15, 2003 6:15 pm    Post subject: Reply with quote

Quote:
I did borrow the theme from Lonkero's sample login script or maybe it was yours...it was a while back...

That was me. Actually, I borrowed heavily from a sample script written for KiXGUI by Alex H.

Don't sweat it, I'm just poking you in the ribs. Wink
Back to top
View user's profile Send private message MSN Messenger
agconmet
KiXforms Follower
KiXforms Follower


Joined: 12 May 2003
Posts: 15

PostPosted: Wed May 21, 2003 10:07 pm    Post subject: Updated Script Reply with quote

A minor update to the AddPrinter Kixform:

1. Got rid of unnecessary lines...
2. Change the mouse pointer to Hourglass when installing printer so user knows he/she needs to wait. Change the mouse point back to default when done installing printer.
3. Put in Sealeopard's code for checking OS. Thanks.
4. Moved the IP Address field and JetDirect field on the form so they appear to be centered in the frame they link to.
Back to top
View user's profile Send private message
agconmet
KiXforms Follower
KiXforms Follower


Joined: 12 May 2003
Posts: 15

PostPosted: Wed May 21, 2003 10:11 pm    Post subject: Reply with quote

Shawn, is there any documentation on the GroupBox control?

Sealeopard, how can I read an INI file into my kixform? What format would the INI file look like?
Back to top
View user's profile Send private message
Sealeopard
KiXforms Aficionado
KiXforms Aficionado


Joined: 05 Mar 2003
Posts: 436
Location: Boston, MA

PostPosted: Thu May 22, 2003 1:35 am    Post subject: Reply with quote

Take a look at READPROFILESTRING/WRITEPROFILESTRING

.INI format could be like this
Code:

[LOCATION1 - ENGINEERING HP DesignJet 1055]
PRINTERIP=192.9.220.47
JETDIRECT=J3113A
DRIVERPATH=HP DesignJet 1055 For 2000 & XP\OEMSETUP.INF
REALNAME=HP DesignJet 1055CM by HP
The you just read the sections and loop through it. this way, you can add/remove printers in the .INI without changing the code.
Code:

$printers=split(readprofilestring('printers.ini','',''),chr(10))
for each $printer in $printers
  $printerip=readprofilestring('printers.ini',$printer,'PrinterIP')
next

_________________
Jens

'There are two kinds of vessels, submarines and targets.'
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    KiXforms Forum Index -> Script Archive All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group