balafrus
(Fresh Scripter)
2005-09-12 11:36 AM
printer add: need help...

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.


LonkeroAdministrator
(KiX Master Guru)
2005-09-12 01:12 PM
Re: printer add: need help...

you have gosubs there...
where are the corresponding labels?


balafrus
(Fresh Scripter)
2005-09-12 01:30 PM
Re: printer add: need help...

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



LonkeroAdministrator
(KiX Master Guru)
2005-09-12 01:41 PM
Re: printer add: need help...

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?


LonkeroAdministrator
(KiX Master Guru)
2005-09-12 01:43 PM
Re: printer add: need help...

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.


Mart
(KiX Supporter)
2005-09-12 01:51 PM
Re: printer add: need help...

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....

balafrus
(Fresh Scripter)
2005-09-12 02:00 PM
Re: printer add: need help...

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


balafrus
(Fresh Scripter)
2005-09-12 02:02 PM
Re: printer add: need help...

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.


LonkeroAdministrator
(KiX Master Guru)
2005-09-12 02:10 PM
Re: printer add: need help...

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?


Mart
(KiX Supporter)
2005-09-12 02:10 PM
Re: printer add: need help...

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.


LonkeroAdministrator
(KiX Master Guru)
2005-09-12 02:11 PM
Re: printer add: need help...

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.


Mart
(KiX Supporter)
2005-09-12 02:21 PM
Re: printer add: need help...

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.


balafrus
(Fresh Scripter)
2005-09-13 10:13 AM
Re: printer add: need help...

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.


balafrus
(Fresh Scripter)
2005-09-13 10:22 AM
Re: printer add: need help...

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.


Mart
(KiX Supporter)
2005-09-13 10:50 AM
Re: printer add: need help...

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



balafrus
(Fresh Scripter)
2005-09-13 11:42 AM
Re: printer add: need help...

im damned , i cant put it all on this forum , too big i think...may i put it on many reply ?

BAL.


Mart
(KiX Supporter)
2005-09-13 11:50 AM
Re: printer add: need help...

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.


balafrus
(Fresh Scripter)
2005-09-13 11:50 AM
Re: printer add: need help...

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.


Mart
(KiX Supporter)
2005-09-13 12:00 PM
Re: printer add: need help...

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



balafrus
(Fresh Scripter)
2005-09-13 12:14 PM
Re: printer add: need help...

is

Code:
Use * /delete 



used to delete all mappings ?

BAL.


LonkeroAdministrator
(KiX Master Guru)
2005-09-13 12:24 PM
Re: printer add: need help...

whole lot of syntax errors there mart.

and balafrus' code is not kixtart at all.
"if exist blaah" just does not work.

and that printer mapping.
is there only one printer per room?
do the printers have proper names or do they differ totally from the naming schema?

I say this because like I said above, all you need is at most 5 lines of code if all of the info is here.
don't start coding too soon.
you can see what comes from it.
bad code

and mart, could you clean your code?


balafrus
(Fresh Scripter)
2005-09-13 12:56 PM
Re: printer add: need help...

well , i don't know why don't you like the "if exist" but i did it because i found it in a doc about kix and don't know kix at all...so i'm open to all sugest if you have any..

BAL.


Mart
(KiX Supporter)
2005-09-13 01:02 PM
Re: printer add: need help...

Yeah, should read stuff better.
Just took balafrus's code without reading it properly.
Added lots of ".


Mart
(KiX Supporter)
2005-09-13 01:05 PM
Re: printer add: need help...

Quote:

is

Code:
Use * /delete 



used to delete all mappings ?

BAL.




Yes it is.


balafrus
(Fresh Scripter)
2005-09-13 01:13 PM
Re: printer add: need help...

Excuse me but is your script for Kix 4xx or kix 3xx ?

Cause i got some error messages at startup and cant see them cause of their speed...

BAL.


LonkeroAdministrator
(KiX Master Guru)
2005-09-13 01:17 PM
Re: printer add: need help...

balafrus, if you look again in the manual, exist is a function.
thus it is Exist()

Code:
if exist("myfolder") or exist("myFile") or not exist("yourFile")



now, still...
you don't have kixtart 4.xx but with you can do pretty amazing stuff with 3.62 and it surely is not that old.
just lacks some of the cool newer functionality.

if you can't tell the naming schema (if there is any) for the printers, can't assist you further.

in your attempt in the first post of yours, you just write the reg-value but there is lot more than reg-value to having a printer connected.
thus, use kixtart's inbuild AddPrinterConnection() instead.


balafrus
(Fresh Scripter)
2005-09-13 01:26 PM
Re: printer add: need help...

yes but i don't remmeber who's telling me that i cant with my old version of Kix...

The naming schema, what did u mean of ? the name of the printer and the server ?

Room 604
Printer laser: HPlaserjet604
printer colour: HP604
serveur: PTP7002A01

and the same for other classroom...

BAL.


LonkeroAdministrator
(KiX Master Guru)
2005-09-13 01:41 PM
Re: printer add: need help...

alrighty!
now, if I understood all the pieces properly, all you need for all classes could be...

Code:

;Room XXX
;wksta: PTExXXXayy
;Printer laser: HPlaserjetXXX
;printer colour: hpXXX
;serveur: PTPServerName

if substr(@wksta,1,3) = "PTE"
$Room = substr(@wksta,4,4)
if substr($Room,1,1) = "0" $Room = substr($Room,2) endif ;if number begins with zero, remove it.
$retval = AddPrinterConnection("\\PTPServerName\HPlaserjet"+$Room)
$retval = AddPrinterConnection("\\PTPServerName\HP"+$Room)
endif



that same code works for all rooms.
now, if you want to make the laser the default (as example), you need to have the name of the printer instead of the sharename.
if your sharename and printername on the server are the same, then simply this will do:
Code:

if substr(@wksta,1,3) = "PTE"
$Room = substr(@wksta,4,4)
if substr($Room,1,1) = "0" $Room = substr($Room,2) endif ;if number begins with zero, remove it.
$retval = AddPrinterConnection("\\PTPServerName\HPlaserjet"+$Room)
$retval = SetDefaultPrinter("\\PTPServerName\HPlaserjet"+$Room)
$retval = AddPrinterConnection("\\PTPServerName\HP"+$Room)
endif



and that's it. there is 7 lines but heck... little extra for 3.xx

you understand what I did there?


balafrus
(Fresh Scripter)
2005-09-13 01:57 PM
Re: printer add: need help...

yes but still one problem , the local 705 have only one printer colour and no laser...and 706 use the shared printer from 705 too...

So for the 705-706 only one printer (colour) shared.

BAL.


LonkeroAdministrator
(KiX Master Guru)
2005-09-13 04:45 PM
Re: printer add: need help...

it does not matter.
I thought about it too before posted the code.
when there is no printer, the addprinterconnection just fails to connect the printer, right?
so, it's fine to be there.

for 706 the problem is there.
you have 2 choices.
either share the same printer again with another name too or I will modify the script.

you could have something like:
Code:

if substr(@wksta,1,3) = "PTE"
$Room = substr(@wksta,4,4)
if substr($Room,1,1) = "0" $Room = substr($Room,2) endif
if $Room = "706" $Room = "705" endif ;706 does not have printer, using the one from 705.
$retval = AddPrinterConnection("\\PTPServerName\HPlaserjet"+$Room)
$retval = SetDefaultPrinter("\\PTPServerName\HPlaserjet"+$Room)
$retval = AddPrinterConnection("\\PTPServerName\HP"+$Room)
endif



balafrus
(Fresh Scripter)
2005-09-15 09:04 AM
Re: printer add: need help...

nice one , i will try this and tell you if it works... !

Thanks a lot !

BAL.
(ps: i take my 2nd "C" training yesterday...so please be patient.. )


balafrus
(Fresh Scripter)
2005-09-15 09:54 AM
Re: printer add: need help...

excuse my next noob question but could i use kixtart in local mode , in exemple only one my computer to make my tests...and if i can , how ?

Cause like this i can make all the tests i want (need...) without making some trouble with the other users...

Thanks again !

BAL.


Mart
(KiX Supporter)
2005-09-15 09:58 AM
Re: printer add: need help...

Sure you can. Just run it of your local system from for example a command line window or directly from the editor if it has the option to do so.

pathtokix32\kix32.exe pathttoscript\yourscript.kix


balafrus
(Fresh Scripter)
2005-09-15 10:05 AM
Re: printer add: need help...

rhooo thanks a lot it will help me more then u can think about....

BAL.


Mart
(KiX Supporter)
2005-09-15 10:07 AM
Re: printer add: need help...

Just a small tip.

Don’t forget to put Break on at the top of your script when testing. If its not there and for some reason your script gets stuck or in a loop you cant quit it without being logged of each time.


balafrus
(Fresh Scripter)
2005-09-15 10:30 AM
Re: printer add: need help...

could you please put me an exemple ?

Mart
(KiX Supporter)
2005-09-15 10:43 AM
Re: printer add: need help...

It's easy, just put Break on at the top of your script like this:

Code:

Break on

other kix code goes here



balafrus
(Fresh Scripter)
2005-09-15 10:54 AM
Re: printer add: need help...

oh , ok im thinking about a more evil code like this

Code:

break
if substr(@wksta,1,3) = "PTE" break on
$Room = substr(@wksta,4,4)
if substr($Room,1,1) = "0" $Room = substr($Room,2) endif
if $Room = "706" $Room = "705" endif ;706 does not have printer, using the one from 705.
$retval = AddPrinterConnection("\\PTPServerName\HPlaserjet"+$Room)
$retval = SetDefaultPrinter("\\PTPServerName\HPlaserjet"+$Room)
$retval = AddPrinterConnection("\\PTPServerName\HP"+$Room)
endif




Or something like that...

BAL.


balafrus
(Fresh Scripter)
2005-09-15 11:06 AM
Re: printer add: need help...

here's what i've tried and don't seems to work...

Code:

break on

if substr(@wksta,1,3) = "PTE"
$Room = substr(@wksta,4,4)
if substr($Room,1,1) = "0" $Room = substr($Room,2) endif ;
$retval = AddPrinterConnection("\\PTE0705A06\HP"+$Room)
$retval = SetDefaultPrinter("\\PTP0705A06\HP"+$Room)
endif



Isn't it suppose to connect a printer ? i try this one with kixtart version 4.50 any idea ?

BAL.


balafrus
(Fresh Scripter)
2005-09-15 11:38 AM
Re: printer add: need help...

ok i try this one and it works fine:

Code:

break on

if substr(@wksta,1,5) = "PTE07";
$retval = AddPrinterConnection("\\PTE0705A06\HP705")
$retval = SetDefaultPrinter("\\PTE0705A06\HP705")
endif



But still have some problems to set as a default printer...is the syntax correct ?

BAL.


Mart
(KiX Supporter)
2005-09-15 01:49 PM
Re: printer add: need help...

Syntax looks correct.
What if you put this line directly below the setdefaultprinter line and see what it gives.
The sleep line is just to halt the script so you can read the stuff on the screen.

Code:

?@error @serror
?Sleeping for 5 seconds.....
Sleep 5



balafrus
(Fresh Scripter)
2005-09-15 03:04 PM
Re: printer add: need help...

sorry , wil try on another post cause here , i've take off (uninstall ?) the default printer (microsoft default printer) and can't put it back..

LonkeroAdministrator
(KiX Master Guru)
2005-09-15 03:54 PM
Re: printer add: need help...

lets go back up please.
did you test at all why some of the scripts didn't work?
you must try to understand what is going on.
I mean, the script commands are clear english words so it won't be that hard.

you say your edited code worked but it looks to me just the same as my code.
tell me what this throws on your window:
Code:

break on

if substr(@wksta,1,3) = "PTE"
"part of PTE" ?
$Room = substr(@wksta,4,4)
"Room = " $Room ?
if substr($Room,1,1) = "0"
"Room started with zero, removing it." ?
$Room = substr($Room,2)
"Room is now " $Room ?
endif
"Connecting to Printer '\\PTE0705A06\HP"+$Room+"' "
$retval = AddPrinterConnection("\\PTE0705A06\HP"+$Room)
@error ?
$retval = SetDefaultPrinter("\\PTP0705A06\HP"+$Room)
endif



the default printer...
well, you need to know the printers name and use it instead of the share name if they are different.


balafrus
(Fresh Scripter)
2005-09-15 04:07 PM
Re: printer add: need help...

Code:
ERROR : unknown command [Sleeping]!
Script: C:\Documents and Settings\lionel\Bureau\KiX2010_450\KiX2010.450\kixtart.
kix
Line : 7


got this error when i try this one:
Code:

break on

if substr(@wksta,1,5) = "PTE07";
$retval = AddPrinterConnection("\\PTE0705A06\HP705")
$retval = SetDefaultPrinter("\\PTE0705A06\HP705")
?@error @serror
?Sleeping for 5 seconds.....
Sleep 5

endif



Any idea ?




LonkeroAdministrator
(KiX Master Guru)
2005-09-15 04:15 PM
Re: printer add: need help...

sure you get.
sleeping is not kixtart command.

did you try the script I gave you?


balafrus
(Fresh Scripter)
2005-09-15 04:25 PM
Re: printer add: need help...

not yet , i'll do it right now !

balafrus
(Fresh Scripter)
2005-09-15 04:28 PM
Re: printer add: need help...

Quote:


part of PTE
Room = 0706
Room started with zero, removing it.
Room is now 706
Connecting to Printer '\\PTE0705A06\HP706' 1801




Don't work at all...only got this message..


Les
(KiX Master)
2005-09-15 06:18 PM
Re: printer add: need help...

1801 is ERROR_INVALID_PRINTER_NAME

balafrus
(Fresh Scripter)
2005-09-15 07:00 PM
Re: printer add: need help...

hemm...okay and which name am i suppose to put ?
The printer's share name is HP705....and i think the $room is the cause of the error...

BAL.


Les
(KiX Master)
2005-09-15 07:02 PM
Re: printer add: need help...

Ja, but which function is throwing the error? One uses the share name and the other, the printer name. Are both names the same?

Mart
(KiX Supporter)
2005-09-15 08:30 PM
Re: printer add: need help...

Damn. Quick typing s#cks.

Code:

?"Sleeping for 5 seconds....."



LonkeroAdministrator
(KiX Master Guru)
2005-09-15 10:53 PM
Re: printer add: need help...

you need to now put back the code that is lacking:
Code:

if $Room = "706" $Room = "705" endif ;706 does not have printer, using the one from 705.



and I say, that's 100% the same code as I gave you before.


balafrus
(Fresh Scripter)
2005-09-16 10:35 AM
Re: printer add: need help...

Quote:


D:\KiX2010.450>kix32.exe kixtart.kix

2Le fichier spécifié est introuvable. <- can't find the file....but wich file ?
Sleeping for 5 seconds.....
D:\KiX2010.450>





Here what i've got when i try the following code:
Code:

break on

if substr(@wksta,1,5) = "PTE07";
$retval = AddPrinterConnection("\\PTE0705A06\HP705")
$retval = SetDefaultPrinter("\\PTE0705A06\HP705")
?@error @serror
?"Sleeping for 5 seconds....."
Sleep 5

endif



The printer connect , but not as default..

BAL.


balafrus
(Fresh Scripter)
2005-09-16 11:37 AM
Re: printer add: need help...

damn i think that's my error came frome the name of the printer in the SetDefaultPrinter line ! but can't find the name to put....isn't supposed to be the share name ? \\server\printer ? like here -> \\PTE0705A06\HP705 ??
Heres the script i use @ this moment:
Code:

break on

if substr(@wksta,1,5) = "PTE07"
"part of PTE" ?
$Room = substr(@wksta,4,4)
"Room = " $Room ?
if substr($Room,1,1) = "0"
"Room started with zero, removing it." ?
$Room = substr($Room,2)
"Room is now " $Room ?
endif
"Connecting to Printer '\\PTE0705A06\HP705"
$retval = AddPrinterConnection("\\PTE0705A06\HP705)
@error ?
$retval = SetDefaultPrinter("\\PTE0705A06\HP705")
endif
[/core]

All working fine except the last line setdefaultprinter..

BAL.

balafrus
(Fresh Scripter)
2005-09-16 12:07 PM
Re: printer add: need help...

hem...i'm always gettin an error code 22 or 122 on the SetDefaultPrinter line...what would it says ?

BAL.


balafrus
(Fresh Scripter)
2005-09-16 12:25 PM
Re: printer add: need help...

OK my script works fine , i must think about not to put SetdefaultPrinter BEFORE endif ...

Code:

break on

if substr(@wksta,1,5) = "PTE07"

MESSAGEBOX ("Installation de l'imprimante HP705 en cours...veuillez cliquer sur OK", "printer", 64)
AddPrinterConnection("\\PTE0705A06\HP705")
@error ?

endif


MESSAGEBOX ("définition de l'imprimante par défaut HP705", "printer", 64)
SetDefaultPrinter("\\PTE0705A06\HP705")
@error ?



Here's my final code....last problem , don't work at all with old versions of kix32....so did u know how to translate the setdefaultprinter and addprinterconnection in old kix script ?

T.Y.

BAL.


LonkeroAdministrator
(KiX Master Guru)
2005-09-16 01:31 PM
Re: printer add: need help...

you still didn't even try the ready made script?
you took marts code and even simplified that and then took some comment lines from my code and placed in marts code.

how do you except that to work?


and, addprinterconnection and setdefaultprinter both work fine with really old kixtart versions.
the problem is in your script.
instead of jumping around like crazy, calm down and think what moves you take.


balafrus
(Fresh Scripter)
2005-09-19 12:35 PM
Re: printer add: need help...

ok sorry , my fault , my entire fault...

/auto slap...

In fact , i use a kixtart2.kix in a kixtart.kix and all works fine....if my computer's name is PTE06xxx -> call Kixtart2.kix , if it's name is PTE07xxx , call kixtart3.kix etc etc...and it work really fine...

Thanks a lot for all your help !

BAL.


LonkeroAdministrator
(KiX Master Guru)
2005-09-19 12:37 PM
Re: printer add: need help...

lol.
you couldn't have gone any worse.
well, you could use batch instead of kix scripts.

but, everyone uses his own style.
and some even do it right the first time...


balafrus
(Fresh Scripter)
2005-11-22 09:55 AM
Re: printer add: need help...

hello again, my scripts don't want to run anymore...it install the printer as well but don't wanna put this damn one as default....

Heres the code:


if substr(@wksta,1,7) = "PTE0605"
AddPrinterConnection("\\PTP7002A11\PRL7002A11")
@error ?
SetDefaultPrinter("\\PTP7002A11\PRL7002A11")
@error ?
AddPrinterConnection("\\PTE0605A01\HP605")
@error ?
endif

Any ideas ?

BAL.


LonkeroAdministrator
(KiX Master Guru)
2005-11-22 09:57 AM
Re: printer add: need help...

oh, this one...

k, you missing on some vital info.
what is the error code?
does this printer have same name as it's share?


balafrus
(Fresh Scripter)
2005-11-22 11:09 AM
Re: printer add: need help...

edit: i check the printer's name isnt the same as it'share name....

Printer's name: PCL6 Laserjet
Share name: PRL7002A11

BAL.


balafrus
(Fresh Scripter)
2005-11-22 11:12 AM
Re: printer add: need help...

hem , the error is this:

It connect the printer correctly but don't put it as default printer...


Les
(KiX Master)
2005-11-22 02:56 PM
Re: printer add: need help...

Is the share name different than the printer name?

LonkeroAdministrator
(KiX Master Guru)
2005-11-22 07:31 PM
Re: printer add: need help...

balafrus dear,
there is @ERROR line in YOUR SCRIPT.
what does it say?!?
I'm 110% sure that it did not say what you told me.

anyway, the problem is that setdefaultPrinter() wants the printer name, not share name.