Page 1 of 1 1
Topic Options
#192699 - 2009-03-04 12:01 PM Can someone correct my script?
ThaSySman Offline
Fresh Scripter

Registered: 2008-03-03
Posts: 13
Hi,

I builded the following script. There are several mistakes in it. And it need some adjustment.

** I want to set a Default printer. (hplj4250TN_PCL6)
** When the printers are already installed. Skip the printers in the script

 Code:
;*************************************************************************
;***                        Main logonscript!                          ***
;*************************************************************************

;**********************************************
;Aanmaken van logbestanden
;**********************************************

$DUMMY=SETTITLE("Loginscript")
CLS
? "Momentje  Roy, uw loginscript wordt uitgevoerd..."

? "Algemene netwerkkoppelingen worden aangemaakt..."
;*********************************************************
;Netwerk koppelingen
;*********************************************************

;Public data K:
Use J: /DEL
Use J: "\\*******SERVER*******\Company" /PERSISTENT

;Public data L:
Use J: /DEL
Use J: "\\*******SERVER*******\Company\Documenten" /PERSISTENT

? "Printers"
;*********************************************************
;Printers
;*********************************************************

;installation of printers
? "Printers installeren"
IF @INWIN=1 
	IF READVALUE("HKEY_CURRENT_USER\SOFTWARE\CEXP\Printer","Installatie")<>"3"
	$DUMMY=ADDPRINTERCONNECTION("\\******SERVER******\hpclp3600")
	$DUMMY=ADDPRINTERCONNECTION("\\******SERVER******\HPLaserJ")
	$DUMMY=ADDPRINTERCONNECTION("\\******SERVER******\hplj4100")
	$DUMMY=ADDPRINTERCONNECTION("\\******SERVER******\hplj4250tnplc6")
	$DUMMY=ADDPRINTERCONNECTIOn("\\******SERVER******\samsung_clp510")
	$DUMMY=ADDPRINTERCONNECTION("\\******SERVER******\XeroxWCM")

RETURN


Can someone help me please?


Edited by ThaSySman (2009-03-04 12:13 PM)

Top
#192700 - 2009-03-04 12:14 PM Re: Can someone correct my script? [Re: ThaSySman]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
Hi and welcome to the board.
I alter your code a bit because every If should have an EndIf. The return was not needed. Also you mapped the J drive twice. I changed it to K and L as stated in the comments above the line that deletes and maps the drive.

You should check the printer names because the one you want to set as default is not added or there might be a typo in the name.

 Code:
;*************************************************************************
;***                        Main logonscript!                          ***
;*************************************************************************

;**********************************************
;Aanmaken van logbestanden
;**********************************************

$DUMMY = SetTitle("Loginscript")
CLS
? "Momentje Roy, uw loginscript wordt uitgevoerd..."

? "Algemene netwerkkoppelingen worden aangemaakt..."
;*********************************************************
;Netwerk koppelingen
;*********************************************************

;Public data K:
Use K: /DEL /PERSISTENT
Use K: "\\*******SERVER*******\Company"

;Public data L:
Use L: /DEL /PERSISTENT
Use L: "\\*******SERVER*******\Company\Documenten"

? "Printers"
;*********************************************************
;Printers
;*********************************************************

;installation of printers
? "Printers installeren"
If @INWIN = 1 
	If ReadValue("HKEY_CURRENT_USER\SOFTWARE\CEXP\Printer", "Installatie") <> "3"
		$DUMMY = AddPrinterConnection("\\******SERVER******\hpclp3600")
		$DUMMY = AddPrinterConnection("\\******SERVER******\HPLaserJ")
		$DUMMY = AddPrinterConnection("\\******SERVER******\hplj4100")
		$DUMMY = AddPrinterConnection("\\******SERVER******\hplj4250tnplc6")
		$DUMMY = AddPrinterConnection("\\******SERVER******\samsung_clp510")
		$DUMMY = AddPrinterConnection("\\******SERVER******\XeroxWCM")
		$DUMMY = SetDefaultPrinter("\\******SERVER******\hplj4250TN_PCL6")
	EndIf
EndIf
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#192701 - 2009-03-04 12:29 PM Re: Can someone correct my script? [Re: Mart]
ThaSySman Offline
Fresh Scripter

Registered: 2008-03-03
Posts: 13
Hi Mart!

Thank you very much for you holy quick response! I am going to test it now!

Thanks for the Welcome!! \:\) And thank you for the adjustments!!

Greetings.
Roy

Top
#192702 - 2009-03-04 01:10 PM Re: Can someone correct my script? [Re: ThaSySman]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
hmm...
the script does not write to the installatie-value.
is it coming on it's own?
_________________________
!

download KiXnet

Top
#192703 - 2009-03-04 01:41 PM Re: Can someone correct my script? [Re: Lonkero]
ThaSySman Offline
Fresh Scripter

Registered: 2008-03-03
Posts: 13
Hello Lonkero,

The Installation is coming with the Printers. I have installed that on the server, when connecting, install printer driver. If that is what you mean.

But.. sadly enough. The SetDefault part is not working correctly. It wont set to Default.

Thanks!!

Top
#192704 - 2009-03-04 01:50 PM Re: Can someone correct my script? [Re: ThaSySman]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
What error is being reported by SetDefaultPrinter?

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#192705 - 2009-03-04 01:55 PM Re: Can someone correct my script? [Re: ThaSySman]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
The AddPrinterConnection function wants the share name of the printer and SetDefaultPrinter wants the printer name. The name could be Printer1 but the share could be Printer2 so best practice would be to keep both the same to avoid any issues.

Did you check the names like I posted above? The printer you wanted there as default does not get added so you cannot set it as default.

I would advise you to alter the printer names and not use HP LaserJ, HP4150TNPCL6, etc… Decide on one standard naming procedure and keep the share names and printer names the same.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#192706 - 2009-03-04 02:42 PM Re: Can someone correct my script? [Re: Mart]
ThaSySman Offline
Fresh Scripter

Registered: 2008-03-03
Posts: 13
Hi Mart.

I made a typ mistake. It should be the

$DUMMY = AddPrinterConnection("\\******SERVER******\hplj4250tnplc6")

Which would be Set as default. I got the network share problem sorted out. But now i only have to set that printer to default hehe ;\)

But thanks so far!!!!

@ Mart... Zou je het ook in het Nederlands kunnen vertalen voor me.. of me eventueel toevoegen op MSN ofietsdergelijks ;\) Altijd handig om een KiX expert in de buurt te hebben ;-) (evt. tegen betaling)


Edited by ThaSySman (2009-03-04 02:47 PM)

Top
#192707 - 2009-03-04 03:20 PM Re: Can someone correct my script? [Re: ThaSySman]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
Well this is an English forum so I'm not going to post Dutch stuff here because other may learn from all posts and then English would work much better the Dutch. I send you a personal message so please check your PM's.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#192708 - 2009-03-04 03:38 PM Re: Can someone correct my script? [Re: Mart]
ThaSySman Offline
Fresh Scripter

Registered: 2008-03-03
Posts: 13
Hi Mart,

I completly understand. Its good to help people and i will try to keep it in English. Thank you for your explination in my PM.

Well. .Back on Topic. I renamed the printers in my server. My login script looks like thin now:

 Code:
;*************************************************************************
;***                        Main logonscript!                          ***
;*************************************************************************

;**********************************************
;Welkom bij XRAY Auto BV.
;**********************************************

$DUMMY=SETTITLE("Loginscript XRAY Auto BV")
CLS
? "Momentje  Roy, uw loginscript wordt uitgevoerd..."

? "Algemene netwerkkoppelingen worden aangemaakt..."
;*********************************************************
;Netwerk koppelingen
;*********************************************************

;Public data K:
Use K: /DEL
Use K: "\\**SERVERNAME**\Company" /PERSISTENT

;Public data L:
Use L: /DEL
Use L: "\\**SERVERNAME**\Company\Documenten\XRAY Auto" /PERSISTENT

;Public data L:
Use Z: /DEL
Use Z: "\\**SERVERNAME**\Private\%UserName%" /PERSISTENT

? "Printers"
;*********************************************************
;Printers
;*********************************************************

;installation of printers
? "Printers installeren"
IF @INWIN=1 
		$DUMMY=ADDPRINTERCONNECTION("\\**SERVERNAME**\PrXRAY-01")
		$DUMMY=ADDPRINTERCONNECTION("\\**SERVERNAME**\PrXRAY-02")
		$DUMMY=ADDPRINTERCONNECTION("\\**SERVERNAME**\PrXRAY-03")
		$DUMMY=ADDPRINTERCONNECTION("\\**SERVERNAME**\PrXRAY-04")
		$DUMMY=ADDPRINTERCONNECTION("\\**SERVERNAME**\PrXRAY-05")
	        $DUMMY=SetDefaultPrinter("\\**SERVERNAME**\PrXRAY-01")

EndIf


Still.. its not setting the Default Printer to the PrXRAY-01

Top
#192709 - 2009-03-04 04:00 PM Re: Can someone correct my script? [Re: ThaSySman]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
What do you see when you add the code below directly after the line that should set the default printer?

 Code:
?"Error code: " @error
?"Error text: " @serror
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#192710 - 2009-03-04 04:04 PM Re: Can someone correct my script? [Re: Mart]
ThaSySman Offline
Fresh Scripter

Registered: 2008-03-03
Posts: 13
Hi Hello Mart,

It says:
Error code: 2
Error text: The system cannot find the specified file


Edited by ThaSySman (2009-03-04 04:05 PM)

Top
#192712 - 2009-03-04 04:13 PM Re: Can someone correct my script? [Re: ThaSySman]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
Ok. Looks like the printer name and the share name are not the same. Check your printer server to see if all printer names and share names are 100% the same.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#192713 - 2009-03-04 04:17 PM Re: Can someone correct my script? [Re: Mart]
ThaSySman Offline
Fresh Scripter

Registered: 2008-03-03
Posts: 13
Okay! You were right!!! You are awsome hehe ;-)

Worked out well. I made a little slip in the shared name. And its working now after 4 refreshes :-)

Very Very great.. thanks.. i am happy!

Top
#192714 - 2009-03-04 04:26 PM Re: Can someone correct my script? [Re: ThaSySman]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
It is not just me that is awesome. Glenn posted about the error codes before I did so he is also awesome

Great that you got it working.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
Page 1 of 1 1


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

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

Generated in 0.065 seconds in which 0.023 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