Page 3 of 4 <1234>
Topic Options
#147557 - 2005-09-15 01:49 PM Re: printer add: need help...
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
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



Edited by Mart (2005-09-15 01:49 PM)
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#147558 - 2005-09-15 03:04 PM Re: printer add: need help...
balafrus Offline
Fresh Scripter

Registered: 2005-09-12
Posts: 33
Loc: Belgium
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..
Top
#147559 - 2005-09-15 03:54 PM Re: printer add: need help...
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
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.
_________________________
!

download KiXnet

Top
#147560 - 2005-09-15 04:07 PM Re: printer add: need help...
balafrus Offline
Fresh Scripter

Registered: 2005-09-12
Posts: 33
Loc: Belgium
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 ?



Top
#147561 - 2005-09-15 04:15 PM Re: printer add: need help...
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
sure you get.
sleeping is not kixtart command.

did you try the script I gave you?
_________________________
!

download KiXnet

Top
#147562 - 2005-09-15 04:25 PM Re: printer add: need help...
balafrus Offline
Fresh Scripter

Registered: 2005-09-12
Posts: 33
Loc: Belgium
not yet , i'll do it right now !
Top
#147563 - 2005-09-15 04:28 PM Re: printer add: need help...
balafrus Offline
Fresh Scripter

Registered: 2005-09-12
Posts: 33
Loc: Belgium
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..

Top
#147564 - 2005-09-15 06:18 PM Re: printer add: need help...
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
1801 is ERROR_INVALID_PRINTER_NAME
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#147565 - 2005-09-15 07:00 PM Re: printer add: need help...
balafrus Offline
Fresh Scripter

Registered: 2005-09-12
Posts: 33
Loc: Belgium
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.

Top
#147566 - 2005-09-15 07:02 PM Re: printer add: need help...
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Ja, but which function is throwing the error? One uses the share name and the other, the printer name. Are both names the same?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#147567 - 2005-09-15 08:30 PM Re: printer add: need help...
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
Damn. Quick typing s#cks.

Code:

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

_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#147568 - 2005-09-15 10:53 PM Re: printer add: need help...
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
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.
_________________________
!

download KiXnet

Top
#147569 - 2005-09-16 10:35 AM Re: printer add: need help...
balafrus Offline
Fresh Scripter

Registered: 2005-09-12
Posts: 33
Loc: Belgium
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.

Top
#147570 - 2005-09-16 11:37 AM Re: printer add: need help...
balafrus Offline
Fresh Scripter

Registered: 2005-09-12
Posts: 33
Loc: Belgium
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.
Top
#147571 - 2005-09-16 12:07 PM Re: printer add: need help...
balafrus Offline
Fresh Scripter

Registered: 2005-09-12
Posts: 33
Loc: Belgium
hem...i'm always gettin an error code 22 or 122 on the SetDefaultPrinter line...what would it says ?

BAL.

Top
#147572 - 2005-09-16 12:25 PM Re: printer add: need help...
balafrus Offline
Fresh Scripter

Registered: 2005-09-12
Posts: 33
Loc: Belgium
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.

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

Registered: 2001-06-05
Posts: 22346
Loc: OK
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.
_________________________
!

download KiXnet

Top
#147574 - 2005-09-19 12:35 PM Re: printer add: need help...
balafrus Offline
Fresh Scripter

Registered: 2005-09-12
Posts: 33
Loc: Belgium
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.

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

Registered: 2001-06-05
Posts: 22346
Loc: OK
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...
_________________________
!

download KiXnet

Top
#147576 - 2005-11-22 09:55 AM Re: printer add: need help...
balafrus Offline
Fresh Scripter

Registered: 2005-09-12
Posts: 33
Loc: Belgium
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.

Top
Page 3 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 259 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.073 seconds in which 0.026 seconds were spent on a total of 13 queries. Zlib compression enabled.

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