Page 1 of 1 1
Topic Options
#212036 - 2016-10-19 02:07 PM ENDIF parameter?
akselc Offline
Just in Town

Registered: 2016-10-19
Posts: 2
Loc: Norway
Hello

Short script to map printers based on groups, but it seems that the first group maps all printers, i thought the ENDIF parameter should stop the script in my kix, or am i wrong? Group Print_Lager should in my mind only get the Xerox WorkCentre 7855 PS printer ?
And the other groups, should get the corresponding printers under the ifingroup syntax? Server2012

 Code:
If InGroup("Print_Lager")
DELPRINTERCONNECTION("\\SERVER\HP LaserJet 600 (RESEPSJON)")
DELPRINTERCONNECTION("\\SERVER\HP LaserJet 600 M601 (NPID8D2BE) Ny")
DELPRINTERCONNECTION("\\SERVER\RICOH MP C4503 (NY)")
DELPRINTERCONNECTION("\\SERVER\Xerox WorkCentre 7855 PS")
AddPrinterConnection("\\SERVER\Xerox WorkCentre 7855 PS")
SetDefaultPrinter("\\SERVER\Xerox WorkCentre 7855 PS")
ENDIF
If InGroup("Print_Admin")
DELPRINTERCONNECTION("\\SERVER\RICOH MP C4503 (NY)")
DELPRINTERCONNECTION("\\SERVER\RICOH VISMA")
DELPRINTERCONNECTION("\\SERVER\HP LaserJet 600 M601 (NPID8D2BE) Ny")
AddPrinterConnection("\\SERVER\RICOH MP C4503 (NY)")
AddPrinterConnection("\\SERVER\RICOH VISMA")
AddPrinterConnection("\\SERVER\HP LaserJet 600 M601 (NPID8D2BE) Ny")
SetDefaultPrinter("\\SERVER\RICOH MP C4503 (NY)")
ENDIF
If InGroup("Print_Resepsjon")
DELPRINTERCONNECTION("\\SERVER\RICOH MP C4503 (NY)")
DELPRINTERCONNECTION("\\SERVER\RICOH VISMA")
DELPRINTERCONNECTION("\\SERVER\HP LaserJet 600 M601 (NPID8D2BE) Ny")
AddPrinterConnection("\\SERVER\RICOH VISMA")
AddPrinterConnection("\\SERVER\RICOH MP C4503 (NY)")
SetDefaultPrinter("\\SORLIEDC\HP LaserJet 600 (RESEPSJON)")

Tnx for any help -
Best regards!


Edited by Mart (2016-10-19 02:45 PM)
Edit Reason: Added code tags.

Top
#212037 - 2016-10-19 02:54 PM Re: ENDIF parameter? [Re: akselc]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
An EndIf will terminate the If statement but it will not terminate the further execution of the script.

If just one condition should be true and executed then you could use Select - Case - EndSelect like show below. If one Case statement is true then all other Case statements are skipped.

 Code:
Select
	Case InGroup("Print_Lager")
		DelPrinterConnection("\\SERVER\HP LaserJet 600 (RESEPSJON)")
		DelPrinterConnection("\\SERVER\HP LaserJet 600 M601 (NPID8D2BE) Ny")
		DelPrinterConnection("\\SERVER\RICOH MP C4503 (NY)")
		DelPrinterConnection("\\SERVER\Xerox WorkCentre 7855 PS")
		AddPrinterConnection("\\SERVER\Xerox WorkCentre 7855 PS")
		SetDefaultPrinter("\\SERVER\Xerox WorkCentre 7855 PS")
	Case InGroup("Print_Admin")
		DelPrinterConnection("\\SERVER\RICOH MP C4503 (NY)")
		DelPrinterConnection("\\SERVER\RICOH VISMA")
		DelPrinterConnection("\\SERVER\HP LaserJet 600 M601 (NPID8D2BE) Ny")
		AddPrinterConnection("\\SERVER\RICOH MP C4503 (NY)")
		AddPrinterConnection("\\SERVER\RICOH VISMA")
		AddPrinterConnection("\\SERVER\HP LaserJet 600 M601 (NPID8D2BE) Ny")
		SetDefaultPrinter("\\SERVER\RICOH MP C4503 (NY)")
	Case InGroup("Print_Resepsjon")
		DelPrinterConnection("\\SERVER\RICOH MP C4503 (NY)")
		DelPrinterConnection("\\SERVER\RICOH VISMA")
		DelPrinterConnection("\\SERVER\HP LaserJet 600 M601 (NPID8D2BE) Ny")
		AddPrinterConnection("\\SERVER\RICOH VISMA")
		AddPrinterConnection("\\SERVER\RICOH MP C4503 (NY)")
		SetDefaultPrinter("\\SORLIEDC\HP LaserJet 600 (RESEPSJON)")
EndSelect
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#212043 - 2016-10-20 08:53 AM Re: ENDIF parameter? [Re: Mart]
akselc Offline
Just in Town

Registered: 2016-10-19
Posts: 2
Loc: Norway
 Originally Posted By: Mart
An EndIf will terminate the If statement but it will not terminate the further execution of the script.

If just one condition should be true and executed then you could use Select - Case - EndSelect like show below. If one Case statement is true then all other Case statements are skipped.

 Code:
Select
	Case InGroup("Print_Lager")
		DelPrinterConnection("\\SERVER\HP LaserJet 600 (RESEPSJON)")
		DelPrinterConnection("\\SERVER\HP LaserJet 600 M601 (NPID8D2BE) Ny")
		DelPrinterConnection("\\SERVER\RICOH MP C4503 (NY)")
		DelPrinterConnection("\\SERVER\Xerox WorkCentre 7855 PS")
		AddPrinterConnection("\\SERVER\Xerox WorkCentre 7855 PS")
		SetDefaultPrinter("\\SERVER\Xerox WorkCentre 7855 PS")
	Case InGroup("Print_Admin")
		DelPrinterConnection("\\SERVER\RICOH MP C4503 (NY)")
		DelPrinterConnection("\\SERVER\RICOH VISMA")
		DelPrinterConnection("\\SERVER\HP LaserJet 600 M601 (NPID8D2BE) Ny")
		AddPrinterConnection("\\SERVER\RICOH MP C4503 (NY)")
		AddPrinterConnection("\\SERVER\RICOH VISMA")
		AddPrinterConnection("\\SERVER\HP LaserJet 600 M601 (NPID8D2BE) Ny")
		SetDefaultPrinter("\\SERVER\RICOH MP C4503 (NY)")
	Case InGroup("Print_Resepsjon")
		DelPrinterConnection("\\SERVER\RICOH MP C4503 (NY)")
		DelPrinterConnection("\\SERVER\RICOH VISMA")
		DelPrinterConnection("\\SERVER\HP LaserJet 600 M601 (NPID8D2BE) Ny")
		AddPrinterConnection("\\SERVER\RICOH VISMA")
		AddPrinterConnection("\\SERVER\RICOH MP C4503 (NY)")
		SetDefaultPrinter("\\SORLIEDC\HP LaserJet 600 (RESEPSJON)")
EndSelect


Ahh. Ok, Mart, thank you so much, i'll try this asap!


Edited by akselc (2016-10-20 08:53 AM)

Top
#212047 - 2016-10-20 03:27 PM Re: ENDIF parameter? [Re: akselc]
Henriques Offline
Fresh Scripter

Registered: 2007-09-13
Posts: 43
The last If has no EndIf.
Top
Page 1 of 1 1


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

Who's Online
0 registered and 1383 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.06 seconds in which 0.025 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