Page 1 of 1 1
Topic Options
#200279 - 2010-10-18 09:59 AM Omitting one user from script
sparkie Offline
Getting the hang of it

Registered: 2010-09-14
Posts: 92
Loc: UK
I want to rollout a command to all domain users bar one, something along the lines of if member of but if user = don't run/shell

Would anyone be able to assist?

Thanks

Top
#200280 - 2010-10-18 11:07 AM Re: Omitting one user from script [Re: sparkie]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Sure, here you go.

 Code:
If @USERID <> "ExcludedUser"
	;do stuff
EndIf
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#200285 - 2010-10-18 04:08 PM Re: Omitting one user from script [Re: Mart]
sparkie Offline
Getting the hang of it

Registered: 2010-09-14
Posts: 92
Loc: UK
Thanks Mart,

Should I still use the () or does it not matter?

("username")

Top
#200286 - 2010-10-18 04:12 PM Re: Omitting one user from script [Re: sparkie]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
No. Brackets are only for functions line WriteLine(), ReadValue(), etc..
You do not need brackets for an If statement.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#200484 - 2010-11-03 10:11 AM Re: Omitting one user from script [Re: Mart]
sparkie Offline
Getting the hang of it

Registered: 2010-09-14
Posts: 92
Loc: UK
Mart, works fine btw so thatbks for that.

Now I want to expand a little to still omit the one user and only apply to one group that run the command. So is there If @USERID <> "ExcludedUser"
but if member of run?

Thanks,

Mark

Top
#200485 - 2010-11-03 10:39 AM Re: Omitting one user from script [Re: sparkie]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Great to hear that you got it running.
Running it on group membership is also not so hard.

 Code:
If @USERID <> "ExcludedUser"
	If InGroup("groupname")
		;do stuff
	EndIf
EndIf


This way it will only run when the username is not the same as the excluded user and the current user is a member of the group.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#200510 - 2010-11-05 03:29 PM Re: Omitting one user from script [Re: Mart]
sparkie Offline
Getting the hang of it

Registered: 2010-09-14
Posts: 92
Loc: UK
Mart, thanks for that. Noticed you've used brackets, is there a reason for that?
Top
#200511 - 2010-11-05 03:34 PM Re: Omitting one user from script [Re: sparkie]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
That’s the difference between commands and functions.

Kix commands do not require brackets and function do require brackets. InGroup is a function so it requires brackets. If you use for example the Copy command you do not need brackets.


Edited by Mart (2010-11-05 03:35 PM)
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#200809 - 2010-11-26 08:06 PM Re: Omitting one user from script [Re: Mart]
MattColeman Offline
Fresh Scripter

Registered: 2008-05-19
Posts: 12
Loc: Kitchener-Waterloo, ON
I use this little command if I want a script to exit for one user:

IF %USERNAME% = "username"
Quit
EndIf

Simple, and works.


Edited by MattColeman (2010-11-26 08:06 PM)

Top
#200810 - 2010-11-26 08:10 PM Re: Omitting one user from script [Re: MattColeman]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Quit and Exit have an optional parm that well... isn't all that optional. In the absence of the parm, under some conditions, it will execute a following statement to try to get the parm from it. Best to always include the parm.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

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

Generated in 0.187 seconds in which 0.124 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