Page 1 of 4 1234>
Topic Options
#147517 - 2005-09-12 11:36 AM printer add: need help...
balafrus Offline
Fresh Scripter

Registered: 2005-09-12
Posts: 33
Loc: Belgium
Hi im new on your forum , and noob with Kix...so,i'm suppose to change the printer by the WKS classroom type with the printer...so if a WKS is in classroom 604 , it's suppose to be connected with printer X and if in 705 , printer Y..etc...etc...

Here's an example of the old script and what i change inside , but don't work properly , block at 45% loading...

Finally excuse my english , im from belgium and don't practice too much my english...

Here's the OLD version of my script:
Code:

;********imprimantes****************
$Percent =45
$StatusMessage = $statmsg6
Gosub Progress

if $wksType<>"PTP"
$defptr="\\PTP"+substr(@DOMAIN,3,4)+$ccmid+$pool+"1\HP LaserJet 2100 Series PCL 6,winspool,Ne00:"
writevalue("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows","Device",$defptr,"REG_SZ")
else
$defptr="\\PTP"+substr(@DOMAIN,3,4)+$ccmid+$pool+"1\HP LaserJet 2100 Series PCL 6,winspool,LPT1:"
writevalue("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows","Device",$defptr,"REG_SZ")
endif
if @error<>0
$17="Mapping HP Laser"
endif
if ingroup ("GB-Eleves")
select
case $pool=0
gosub "Printer_Pool1"
case $pool=1
gosub "Printer_Pool2"
case $pool=3
gosub "Printer_Pool3"
endselect
if $wksType="PTE"
shell "cmd /c rd d:\temp /s /q"
md d:\temp
endif
$Percent =50
Gosub Progress
endif

if ingroup ("GB-Professeurs") Or ingroup ("GB-PersRessources") Or ingroup ("Administrateurs")
if $wksType="PTE" or $wksType="PTP"
select
case $pool=0
gosub "Printer_Pool1"
case $pool=1
gosub "Printer_Pool2"
case $pool=3
gosub "Printer_Pool3"
endselect
$Percent =50
Gosub Progress
endif
if $wksType="PTD" or $wksType="PTM"
$laser1="PRL"+substr(@DOMAIN,3,4)+$ccmid+"01"
$laser2="PRL"+substr(@DOMAIN,3,4)+$ccmid+"11"
$srvQL1="\\PTP"+substr(@DOMAIN,3,4)+$ccmid+"01\"+$laser1
$srvQL2="\\PTP"+substr(@DOMAIN,3,4)+$ccmid+"11\"+$laser2
$srvQL=$srvQL1
gosub "Printer_Pool1"
$srvQL=$srvQL2
gosub "Printer_Pool2"
$Percent =50
Gosub Progress
endif
gosub "Printer_Color"
$Percent =55
Gosub Progress
endif
$Percent =60
$StatusMessage = $statmsg7
Gosub Progress



As i need ot connect 5 printer for spécifics classroom , here's what i did:
New code:
Code:

;********imprimantes****************
$Percent =45
$StatusMessage = $statmsg6
Gosub Progress

if $wksType<>"PTP"
$defptr="\\PTP"+substr(@DOMAIN,3,4)+$ccmid+$pool+"1\HP LaserJet 2100 Series
PCL 6,winspool,Ne00:"
writevalue("HKEY_CURRENT_USER\Software\Microsoft\Windows
NT\CurrentVersion\Windows","Device",$defptr,"REG_SZ")
else
$defptr="\\PTP"+substr(@DOMAIN,3,4)+$ccmid+$pool+"1\HP LaserJet 2100 Series
PCL 6,winspool,LPT1:"
writevalue("HKEY_CURRENT_USER\Software\Microsoft\Windows
NT\CurrentVersion\Windows","Device",$defptr,"REG_SZ")
endif
if @error<>0
$17="Mapping HP Laser"
endif
if ingroup ("GB-Eleves")
select
case $pool=0
gosub "Printer_Pool1"
case $pool=1
gosub "Printer_Pool2"
case $pool=3
gosub "Printer_Pool3"
endselect
if $wksType="PTE"
shell "cmd /c rd d:\temp /s /q"
md d:\temp
endif


************ SCRIPT MODIFIE PAR BALAFRUS ***********************
if $wksType<>"PTE0604"
$defptr="\\PTP7002A01\HP LaserJet 2100 Series
PCL 6,winspool,Ne00:"
writevalue("HKEY_CURRENT_USER\Software\Microsoft\Windows
NT\CurrentVersion\Windows","Device",$defptr,"REG_SZ")
endif

if $wksType<>"PTE0605"
$defptr="\\PTP7002A11\HP LaserJet 2100 Series
PCL 6,winspool,Ne00:"
writevalue("HKEY_CURRENT_USER\Software\Microsoft\Windows
NT\CurrentVersion\Windows","Device",$defptr,"REG_SZ")
endif

if $wksType<>"PTE0705"
$defptr="\\PTE0705A06\HP705,winspool,Ne00:"
writevalue("HKEY_CURRENT_USER\Software\Microsoft\Windows
NT\CurrentVersion\Windows","Device",$defptr,"REG_SZ")
endif

if $wksType<>"PTE0706"
$defptr="\\PTE0705A06\HP705,winspool,Ne00:"
writevalue("HKEY_CURRENT_USER\Software\Microsoft\Windows
NT\CurrentVersion\Windows","Device",$defptr,"REG_SZ")
endif
***************************************************************



Please excuse me if i make a forum mistake ....im noob...

And if u can bring me to light with this script....thanks a lot !

BAL.


Edited by balafrus (2005-09-12 12:19 PM)

Top
#147518 - 2005-09-12 01:12 PM Re: printer add: need help...
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
you have gosubs there...
where are the corresponding labels?
_________________________
!

download KiXnet

Top
#147519 - 2005-09-12 01:30 PM Re: printer add: need help...
balafrus Offline
Fresh Scripter

Registered: 2005-09-12
Posts: 33
Loc: Belgium
Okay , i think that's what you speak about...scuse me but i don't know anything @ Kix32...

Code:

;********laser 1**************************
:Printer_Pool1
if $wkstype="PTP" and $wksorder="01"
$statlaser=$loc
else
if addprinterconnection ($srvQL) = 0
$statlaser=$ok
else
$statlaser=$abs
endif
endif
$def_print="HP Laser Pool1 "+$statlaser
if $statlaser=$ok or $statlaser=$loc
$nul = oleputproperty ( $frmprint, "innerhtml", "s", 'color="#FFFF00">$def_print' )
else
$nul = oleputproperty ( $frmprint, "innerhtml", "s", 'color="#FF0000">$def_print' )
endif
return

;********laser 2**************************
:Printer_Pool2
$ptp11="\\PTP"+substr(@DOMAIN,3,4)+$ccmid+"11"
shell "net view $ptp11"
if @error=0
if $wkstype="PTP" and $wksorder="11"
$statlaser=$loc
else
if addprinterconnection ($srvQL) = 0
$statlaser=$ok
else
$statlaser=$abs
endif
endif
$def_print="HP Laser Pool2 "+$statlaser
if $statlaser=$ok or $statlaser=$loc
$nul = oleputproperty ( $frmprint, "innerhtml", "s", 'color="#FFFF00">$def_print' )
else
$nul = oleputproperty ( $frmprint, "innerhtml", "s", 'color="#FF0000">$def_print' )
endif
else
$statlaser=$nex
endif
return

;********laser 3**************************
:Printer_Pool3
$ptp31="\\PTP"+substr(@DOMAIN,3,4)+$ccmid+"31"
shell "net view $ptp31"
if @error=0
if $wkstype="PTP" and $wksorder="31"
$statlaser=$loc
else
if addprinterconnection ($srvQL) = 0
$statlaser=$ok
else
$statlaser=$abs
endif
endif
$def_print="HP Laser Pool3 "+$statlaser
if $statlaser=$ok or $statlaser=$loc
$nul = oleputproperty ( $frmprint, "innerhtml", "s", 'color="#FFFF00">$def_print' )
else
$nul = oleputproperty ( $frmprint, "innerhtml", "s", 'color="#FF0000">$def_print' )
endif
else
$statlaser=$nex
endif
return

;********couleur**************************
:Printer_Color
if $wkstype<>"PTP" and $wksorder="21"
$statcolor=$loc
else
if addprinterconnection ($srvQC) = 0
$statcolor=$ok
else
$statcolor=$abs
endif
endif
$print_2="HP Deskjet "+$statcolor
if $statcolor=$ok or $statcolor=$loc
$nul = oleputproperty ( $frmprint2, "innerhtml", "s", 'color="#FFFF00">$print_2' )
else
$nul = oleputproperty ( $frmprint2, "innerhtml", "s", 'color="#FF0000">$print_2' )
endif
return


Top
#147520 - 2005-09-12 01:41 PM Re: printer add: need help...
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
oleput?
may I ask what version of kix you are using?

can I offer you a trade?
you download the newist, kixtart 2010 4.50 from kixtart.org/downloads and we help you build the script with the new sh*t.

what you say?
_________________________
!

download KiXnet

Top
#147521 - 2005-09-12 01:43 PM Re: printer add: need help...
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
oh... come to think about it...
your script might be so huge with all the ole stuff that it may take quite a long time to translate that to COM.
_________________________
!

download KiXnet

Top
#147522 - 2005-09-12 01:51 PM Re: printer add: need help...
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
If he's running AD and can make computer groups for the classrooms and put the comps in the groups we could just use the ComputerInGroup() udf. and then just map printer A on computer group A, printer B on computer group B, etc....
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#147523 - 2005-09-12 02:00 PM Re: printer add: need help...
balafrus Offline
Fresh Scripter

Registered: 2005-09-12
Posts: 33
Loc: Belgium
AD don't exist in NT4 server...my version of KiXtart ? i don't even know...but old i bet...i'm new at my job and just discover that they haven't a right server...and im suppose to do the best with this crappy server and this script...
Any idea of what can i do to do what i need ?

BAL.
Thx to read me at least

Top
#147524 - 2005-09-12 02:02 PM Re: printer add: need help...
balafrus Offline
Fresh Scripter

Registered: 2005-09-12
Posts: 33
Loc: Belgium
ok i check my KiXtart version , ....hem.... 3.62....sorry...i know it's sooooo old but i'm suppose to do it with what i've got..

BAL.

Top
#147525 - 2005-09-12 02:10 PM Re: printer add: need help...
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
what you mean with crappy server?
NT is about the best thing redmont has produced this far

in my opinion, you should try to make your subscript printerPool a generic one so you can call it for all of the pools.

also, you use regwrites but instead you should go with kixtart's addPrinterConnection() and setDefaultPrinter()

now, is there a proper classroom naming in place?
like, all the wksta's in one room share the same naming concept?

if yes, make a nice list showing what printer is connected to what classroom and what is the way to identify a wksta belonging to that classroom.
if there is more than one printer that's fine too.

why I say you to do this, is that the whole printer add code should be no more than 5 lines all together.
with proper planning it is easier to write clean short code, right?
_________________________
!

download KiXnet

Top
#147526 - 2005-09-12 02:10 PM Re: printer add: need help...
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
Quote:


AD don't exist in NT4 server...





Yes I know that but you never said you used NT4.

Updating kix is easy and free of charge. Lots more functions and support for more OS versions etc... in the newest kix version.
All you have to do is copy kix32.exe to the location the old one is sitting and overwrite this old version with the new 4.50.
No charge, ten seconds of work, more support, more options, better help from everybody on this board, etc..... If even remotely possible I would update to 4.50 right now. 3.62 is realy old.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#147527 - 2005-09-12 02:11 PM Re: printer add: need help...
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
like said, it's not that easy in his case.
if he is using ole, that's not supported no more in 4.xx

he should avoid updating before he gets to know kixtart a little better.
_________________________
!

download KiXnet

Top
#147528 - 2005-09-12 02:21 PM Re: printer add: need help...
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
Quote:

like said, it's not that easy in his case.
if he is using ole, that's not supported no more in 4.xx





Yep, I know. Changing it to build-in kix commands and functions would golf it down a lot.

Quote:


he should avoid updating before he gets to know kixtart a little better.





That for sure. We could give him some kind of push in the right direction if the stuff you asked like standard naming by classroom number or something like it is in place. If not, he should first get the naming properly set up and then think about changing the script.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#147529 - 2005-09-13 10:13 AM Re: printer add: need help...
balafrus Offline
Fresh Scripter

Registered: 2005-09-12
Posts: 33
Loc: Belgium
Well let's try to explain a little bit my situation , i've to manage an NT4 server based network , Kix was installed before my arrival , so i must work with it but i can change to new version if i got a little hand to help me...

The classroom are supposed to be like that:


Class 604:
-One laser printer
-One colour printer
-All post named by the same convention (PTExxxxAxx)

Class 605:
-One laser printer
-One colour printer
-All post named by the same convention (PTExxxxAxx)

Class 705-706
-One colour printer
-All post named ...PTExxxxAxx

For all WKS , their names are:

PTE0(local n°)A(machine number)

In ex: PTE0604A01....02...-> 10 Next , PTE0705A01...10...

Am i most clear like this ?

If any help needed , ask me...

Thanks for all your help !

(damn , speaking english is so hard for me... please don't laugh...:p)

BAL.


Edited by balafrus (2005-09-13 10:13 AM)

Top
#147530 - 2005-09-13 10:22 AM Re: printer add: need help...
balafrus Offline
Fresh Scripter

Registered: 2005-09-12
Posts: 33
Loc: Belgium
Hem , i think about one thing , should it help you if i put my all script here ? it's a little bit big but i think i can put it on this forum...

BAL.

Top
#147531 - 2005-09-13 10:50 AM Re: printer add: need help...
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
Changing to a new version is easy. If you know where the old kix32.exe and/or wkix32.exe is located (I bet its locally on each machine). Just download the new version and copy it over the old version.

!! WARNING !!
You current script will not work! As said above commands are used in your current script that are no longer supported by kix. The script should first be altered to work with the new version of kix.
This may also be the case on any other kixscripts you use. BE CAREFULL.

This could be a start of what your printer mapping script could look like. This is a very basic script to add printers based on the computer name.
It deletes all currently installed network printers before adding new ones.

Code:

;deleting all currently installed network printers
DelPrinterConnection("")

;map printers for classroom 604
;and set Laser604 as default printer
If InStr (@WKSTA, "604")
AddPrinterConnection ("\\server\Laser604")
SetDefaultPrinter ("\\server\Laser604")
AddPrinterConnection ("\\server\Colour604")
EndIf

;map printers for classroom 605
;and set Laser605 as default printer
If InStr (@WKSTA, "605")
AddPrinterConnection ("\\server\Laser605")
SetDefaultPrinter ("\\server\Laser605")
AddPrinterConnection ("\\server\Colour605")
EndIf

;map printers for classroom 705
;and set Colour705 as default printer
If InStr (@WKSTA, "705")
AddPrinterConnection ("\\server\Colour705")
SetDefaultPrinter ("\\server\Colour705")
EndIf

;map printers for classroom 706
;and set Colour706 as default printer
If InStr (@WKSTA, "706")
AddPrinterConnection ("\\server\Colour706")
SetDefaultPrinter ("\\server\Colour706")
EndIf

_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#147532 - 2005-09-13 11:42 AM Re: printer add: need help...
balafrus Offline
Fresh Scripter

Registered: 2005-09-12
Posts: 33
Loc: Belgium
im damned , i cant put it all on this forum , too big i think...may i put it on many reply ?

BAL.

Top
#147533 - 2005-09-13 11:50 AM Re: printer add: need help...
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
How big is big? 1000's of lines, 250 scripts, 20MB per script
Sure you can put it here. As long as it's you’re printer mapping script.
Maybe it's best to start a new topic if you need help converting an other script from oldie retired and gray haired kix to the current version.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#147534 - 2005-09-13 11:50 AM Re: printer add: need help...
balafrus Offline
Fresh Scripter

Registered: 2005-09-12
Posts: 33
Loc: Belgium
Here's my first try to connect some network ressources:

Code:

if ingroup("GB-Professeur")

if exist h:
goto :exist
else
Net use h: \\SRV7002A01\Forum
? Forum connecté


if exist i:
goto :exist
else
Net use i: \\SRV7002A01\Prive
? Privé connecté

if exist j:
goto :exist
else
Net use j: \\SRV7002A01\public
?Public connecté

if exist k:
goto :exist
else
Net use k: \\SRV7002A01\eleves
? Eleves connecté

if exist l:
goto :exist
else
Net use l: \\SRV7002A01\bcd
? BCD connecté

ENDIF

if ingroup("domain user")

if exist h:
goto :exist
else
Net use h: \\SRV7002A01\Forum
? Forum connecté

if exist k:
goto :exist
else
Net use k: \\SRV7002A01\eleves
? Eleves connecté

Endif



Am i good ?

BAL.

Top
#147535 - 2005-09-13 12:00 PM Re: printer add: need help...
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
Took out the GOTO's (don't use them, they are EVIL )
The ?@error @SERROR lines are there for debugging. If all goes ok you can comment them by putting a ; in front of them or just remove them.
Kix does not use NET USE but just USE.
It deletes all network drive before adding new ones because the users can disconnect a drive and map a new one on the same drive name so it looks like the drive is there but it points to the wrong share.


Code:

If InGroup("GB-Professeur")
Use * /delete
?@error @SERROR
Use h: "\\SRV7002A01\Forum"
?@error @SERROR
Use i: "\\SRV7002A01\Prive"
?@error @SERROR
Use j: "\\SRV7002A01\public"
?@error @SERROR
Use k: "\\SRV7002A01\eleves"
?@error @SERROR
Use l: "\\SRV7002A01\bcd"
?@error @SERROR
EndIf

If InGroup("domain user")
Use * /delete
?@error @SERROR
Use h: "\\SRV7002A01\Forum"
?@error @SERROR
Use k: "\\SRV7002A01\eleves"
?@error @SERROR
EndIf



Edited by Mart (2005-09-14 11:11 AM)
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#147536 - 2005-09-13 12:14 PM Re: printer add: need help...
balafrus Offline
Fresh Scripter

Registered: 2005-09-12
Posts: 33
Loc: Belgium
is

Code:
Use * /delete 



used to delete all mappings ?

BAL.

Top
Page 1 of 4 1234>


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 507 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.074 seconds in which 0.024 seconds were spent on a total of 14 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org