Page 1 of 1 1
Topic Options
#143183 - 2005-07-07 04:10 PM Printer mapping using ascan
puck5151 Offline
Fresh Scripter

Registered: 2002-05-08
Posts: 11
Hi, having difficulties with the following script...

;Map HP12whse Printer
$SystemList = 'terminalserver','testserver','dbserver3','printserver',"
If AScan ($SystemList, @WKSTA)>=0
;Do nothing
Else
IF INGROUP("HP12whse")
If AddPrinterConnection ("\\printserver\HP12whse") = 0
? "Attach network printer \\printserver\HP12whse"
Endif
EndIf

Everything looks good but hangs up as soon as it hits "if ingroup".

Thanks.

Top
#143184 - 2005-07-07 04:53 PM Re: Printer mapping using ascan
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
Code:

;Map HP12whse Printer
$SystemList = 'terminalserver','testserver','dbserver3','printserver' ;<--- there was an extra ," at the end of this line
If AScan ($SystemList, @WKSTA) = -1 ;<--- changed this line to check for ascan returning a -1, not in array, making the IF TRUE
IF INGROUP("HP12whse")
If AddPrinterConnection ("\\printserver\HP12whse") = 0
? "Attach network printer \\printserver\HP12whse"
Endif
endif ;<--- you were missing an ENDIF
EndIf


Top
#143185 - 2005-07-07 05:06 PM Re: Printer mapping using ascan
puck5151 Offline
Fresh Scripter

Registered: 2002-05-08
Posts: 11
Worked like a charm, thanks Bryce.
Top
#143186 - 2005-07-07 05:58 PM Re: Printer mapping using ascan
puck5151 Offline
Fresh Scripter

Registered: 2002-05-08
Posts: 11
Bryce, I would like to exclude the servers listed in the ascan from mapping the printers, any thoughts?

Thanks.

Top
#143187 - 2005-07-07 06:05 PM Re: Printer mapping using ascan
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
they are excluded with the above code already.
_________________________
!

download KiXnet

Top
#143188 - 2005-07-07 06:09 PM Re: Printer mapping using ascan
puck5151 Offline
Fresh Scripter

Registered: 2002-05-08
Posts: 11
That's what I thought but then I added one of my servers and logged in to test and it mapped all printers.
Top
#143189 - 2005-07-07 06:31 PM Re: Printer mapping using ascan
puck5151 Offline
Fresh Scripter

Registered: 2002-05-08
Posts: 11
It appears that the ascan is being ignored?
Top
#143190 - 2005-07-07 07:10 PM Re: Printer mapping using ascan
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
can't be.
it can't go over the ascan part and jump to inner if-endif.
_________________________
!

download KiXnet

Top
#143191 - 2005-07-07 07:27 PM Re: Printer mapping using ascan
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
Quote:

It appears that the ascan is being ignored?




you changed the code? if so repost it please.

Top
#143192 - 2005-07-07 11:00 PM Re: Printer mapping using ascan
puck5151 Offline
Fresh Scripter

Registered: 2002-05-08
Posts: 11
Here's the code...

;Map HP12whse Printer
$SystemList= 'terminalserver','dbserver3','printserver','mainfileserver','SBCS'
AScan ($SystemList, @WKSTA) = -1
IF INGROUP("HP12WHSE")
If AddPrinterConnection ("\\printserver\HP12WHSE") = 0
? "Attach network printer \\printserver\HP12WHSE"
Endif
endif

The code would not accept another endif at the end.

Top
#143193 - 2005-07-07 11:23 PM Re: Printer mapping using ascan
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
;Map HP12whse Printer
$SystemList= 'terminalserver','dbserver3','printserver','mainfileserver','SBCS'
if AScan ($SystemList, @WKSTA) = -1
IF INGROUP("HP12WHSE")
If AddPrinterConnection ("\\printserver\HP12WHSE") = 0
? "Attach network printer \\printserver\HP12WHSE"
Endif
endif
endif

Top
#143194 - 2005-07-07 11:36 PM Re: Printer mapping using ascan
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
you removed the if.
ascan is a function, it's not expression valuator.
IF IS.
put the if back there and it works fine.

I just can't understand...
one gets given perfect 100% foolproof code on silver platter and it must be screwed up.
just so that he can say he did something.


Edited by Lonkero (2005-07-07 11:37 PM)
_________________________
!

download KiXnet

Top
#143195 - 2005-07-08 10:17 PM Re: Printer mapping using ascan
puck5151 Offline
Fresh Scripter

Registered: 2002-05-08
Posts: 11
Sorry, my bad. As soon as I added the IF expression it worked perfectly. Thanks for noticing that in the code.
Top
#143196 - 2005-07-09 10:02 PM Re: Printer mapping using ascan
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
And please indent your code properly and use the [CODE] tags when posting ocde.
_________________________
There are two types of vessels, submarines and targets.

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 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

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

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