casperinmd
(Fresh Scripter)
2006-04-06 02:51 PM
Do if workstation is in group

Greetings,
I am trying to setup my script to map a PC to a network printer based on the computers group membership.

I have tried If INGROUP but that does not work, it only seems to work if the user is in the group.

Is this possible?


Björn
(Korg Regular)
2006-04-06 02:59 PM
Re: Do if workstation is in group

I don't get it, why do you wanna do that?

Les
(KiX Master)
2006-04-06 03:05 PM
Re: Do if workstation is in group

Yes, it is possible but not with InGroup(). You can find a UDF in our library.

Witto
(MM club member)
2006-04-06 04:34 PM
Re: Do if workstation is in group

ComputerInGroup()

Tiswa
(Fresh Scripter)
2006-04-10 12:17 PM
Re: Do if workstation is in group

is this possible?

If ComputerInGroup($t202)
use t: "\\tessende-llser\wintoets" /PERSISTENT
Endif

thx


Radimus
(KiX Supporter)
2006-04-10 12:30 PM
Re: Do if workstation is in group

what is $t202? a computer or group?

Tiswa
(Fresh Scripter)
2006-04-10 12:42 PM
Re: Do if workstation is in group

t202 is a group

Les
(KiX Master)
2006-04-10 03:03 PM
Re: Do if workstation is in group

Quote:

is this possible?




Yes, but why persistent?


Witto
(MM club member)
2006-04-10 09:10 PM
Re: Do if workstation is in group

I think it should be
Code:

If ComputerInGroup('t202')



Mart
(KiX Supporter)
2006-04-10 09:16 PM
Re: Do if workstation is in group

It all depends on the question if the group name is $t202 or that it is a var that gets filled somewhere with the name of the group.

Tiswa
(Fresh Scripter)
2006-04-11 07:37 AM
Re: Do if workstation is in group

T202 is a group, and persistent is added by the kixstarter script editor, i try If ComputerInGroup('t202') but dit doesn't work.

Tiswa


Gargoyle
(MM club member)
2006-04-11 08:02 AM
Re: Do if workstation is in group

Why don't you post all of the code so that we can see the logical flow process.

Tiswa
(Fresh Scripter)
2006-04-11 02:13 PM
Re: Do if workstation is in group

This is all of it

If ComputerInGroup($t202)
use t: "\\tessende-llser\wintoets" /PERSISTENT
Endif

i also try

If ComputerInGroup(t202)
use t: "\\tessende-llser\wintoets"
Endif


Howard Bullock
(KiX Supporter)
2006-04-11 02:19 PM
Re: Do if workstation is in group

In your first sample, why do you have a variable "$t202" as the name of the group? In the second sample, why is there no quotes around your string "t202"? Have you tried InGroup("domain\group")? I would recommend against using the /Persistent switch.

Howard Bullock
(KiX Supporter)
2006-04-11 02:21 PM
Re: Do if workstation is in group

Have you logged off and back on after adding your test user to this group?

Les
(KiX Master)
2006-04-11 02:37 PM
Re: Do if workstation is in group

Where and how to you define the function? What version @KiX?

Howard Bullock
(KiX Supporter)
2006-04-11 02:53 PM
Re: Do if workstation is in group

Good question Les. If this is all the code, the UDF is definitely missing.

Mart
(KiX Supporter)
2006-04-11 03:01 PM
Re: Do if workstation is in group

ComputerInGroup() - returns if the PC is a member of a specified group

Gargoyle
(MM club member)
2006-04-11 03:09 PM
Re: Do if workstation is in group

It needs to be done like this....

Code:

If ComputerInGroup(t202)
use t: "\\tessende-llser\wintoets"
Endif


Function ComputerInGroup($group,optional $Domain)
Dim $oGrp
if not $domain $domain=@domain endif
$oGrp = GetObject("WinNT://" + $domain + "/" + $group + ",group" )
if @error exit 1 endif

if $oGrp.IsMember("WinNT://" + $domain + "/" + @wksta + "$$" )
$ComputerInGroup=1
else
$ComputerInGroup=0
endif
endfunction



If you don't add the function in the code, then it has nothing to reference against, and it wont work.


Les
(KiX Master)
2006-04-11 03:27 PM
Re: Do if workstation is in group

You are missing quotes. Assuming of course that 't202' is the computer's NetBIOS name.
If ComputerInGroup('t202')


Gargoyle
(MM club member)
2006-04-11 05:21 PM
Re: Do if workstation is in group

[edit][delete]Cut[/delete] Copy[/edit] and paste, gets you everytime.

Better?


Les
(KiX Master)
2006-04-11 05:26 PM
Re: Do if workstation is in group

Quote:

Cut and paste



For me, Cut is greyed out.


Tiswa
(Fresh Scripter)
2006-04-12 07:18 AM
Re: Do if workstation is in group

If ComputerInGroup(t202)
use t: "\\tessende-llser\wintoets"
Endif


Function ComputerInGroup($group,optional $Domain)
Dim $oGrp
if not $domain $domain=@domain endif
$oGrp = GetObject("WinNT://" + $domain + "/" + $group + ",group" )
if @error exit 1 endif

if $oGrp.IsMember("WinNT://" + $domain + "/" + @wksta + "$$" )
$ComputerInGroup=1
else
$ComputerInGroup=0
endif
endfunction

this work perfect Thanks


NTDOCAdministrator
(KiX Master)
2006-04-12 09:52 AM
Re: Do if workstation is in group

Quote:

If ComputerInGroup(t202)





I don't see how that can work. It should give you an error.


The group name should be within quotes
If ComputerInGroup("t202")


Tiswa
(Fresh Scripter)
2006-04-12 01:37 PM
Re: Do if workstation is in group

you are right but kixstarter give's no error

Richard H.Administrator
(KiX Supporter)
2006-04-12 02:21 PM
Re: Do if workstation is in group

Quote:

I don't see how that can work. It should give you an error.




Depends. KiXtart will treat unrecognised text as a string in most circumstances with older versions of KiXtart.

I think that the latest versions will always produce a runtime error.