Page 1 of 1 1
Topic Options
#201413 - 2011-01-18 12:54 PM Only run under certain scenario
sparkie Offline
Getting the hang of it

Registered: 2010-09-14
Posts: 92
Loc: UK
Not sure if this is possible but here goes.

Is there a way to only run something in the script if a user is logging on from a domain PC (XP, Vista or Windows 7) and not a remote domain server (2003/2008) as the same domain user?

Maybe some sort of OS lookup

Thanks

Mark

Top
#201414 - 2011-01-18 02:02 PM Re: Only run under certain scenario [Re: sparkie]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
The @PRODUCTTYPE macro is your best friend for this. Check the macro for key words (like "server") and exit the script, or perform different tasks.

A copy of the manual and the online manual here are your next level friends. The online manual is searchable.

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

Top
#201474 - 2011-02-01 12:09 PM Re: Only run under certain scenario [Re: Glenn Barnas]
sparkie Offline
Getting the hang of it

Registered: 2010-09-14
Posts: 92
Loc: UK
Looking at the @PRODUCTTYPE I stumbled accross the function, so would this work since I only what the command to run on XP/Vista domain PC's and not when they login to a remote server session

Function IsNonServer()
if not (IsMemberServer() or IsDomainController())
$rc = WriteValue("HKEY_CURRENT_USER\Software.......)
else
$IsNonServer = 0
endif
Endfunction

Top
#201475 - 2011-02-01 02:14 PM Re: Only run under certain scenario [Re: sparkie]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4563
Loc: USA
As Glenn suggested, it could be as simple as...

 Code:
if instr(@producttype,"Server") or instr(@producttype,"Domain Controller")
  ;exit 0
else
  ;run the login script
endif

Top
#201503 - 2011-02-07 01:57 PM Re: Only run under certain scenario [Re: Allen]
sparkie Offline
Getting the hang of it

Registered: 2010-09-14
Posts: 92
Loc: UK
Using the exit 0, will that not exit the entire script, or just this part of the script?
Top
#201506 - 2011-02-07 04:50 PM Re: Only run under certain scenario [Re: sparkie]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
If it is in the upper most level of the script (ie..not in a UDF) then yes it should exit the script. You could replace the 'Exit 0' with whatever code you want to be able to run on servers, and replace the line ';run the login script' with whatever code you want to run on non-servers.

 Quote:

Exit

Action: Exits the current KiXtart script, or, if used at the topmost level, exits KiXtart.

Syntax: EXIT [error level / exit code]

Remarks: If EXIT is followed by a numeric expression, then @ERROR is set to the value of that expression and you can check it in the calling script or batch file.

See Also: Return, Quit

The CHM help file is gold if youre beginning out with kix...here's the link.
http://scriptlogic.http.internapcdn.net/scriptlogic//downloads/kixtart/help/kixhelp4.53.zip

Top
#201569 - 2011-02-11 11:37 AM Re: Only run under certain scenario [Re: ShaneEP]
sparkie Offline
Getting the hang of it

Registered: 2010-09-14
Posts: 92
Loc: UK
That's what I thought, if exit is at the top level of the script then exit the entire script, but I don't want it to exit the entire script, I want it to exit if = and do if not =

e.g.

If instr(@producttype,"Server")
exit, (otherwise do the next line)
run "........"
endif

...then continue with the rest of the script.

Top
#201573 - 2011-02-11 02:16 PM Re: Only run under certain scenario [Re: sparkie]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
The easiest way would be to use If not instr(@producttype,"Server") and execute the stuff you want. This will skip everything when the word Server is in @producttype.

 Code:
If Not InStr(@producttype, "Server")
	;do stuff here
EndIf
;Script continues here


Edited by Mart (2011-02-11 02:17 PM)
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#201574 - 2011-02-11 04:18 PM Re: Only run under certain scenario [Re: Mart]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
If you find the "Not" logic confusing just use the Else section. You can leave a placeholder comment in the other section - you never know, you might need it in the future.

 Code:
If InStr(@producttype, "Server")
	; Put your Server actions here
Else
	; Put your non-Server actions here
EndIf

; The rest of the script continues here

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 895 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.062 seconds in which 0.029 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