Page 1 of 1 1
Topic Options
#37815 - 2003-03-12 04:45 PM More than one IF INGROUP statement
Tracy Offline
Fresh Scripter

Registered: 2003-03-12
Posts: 9
As you can see from the script below, I have more than one IF INGROUP statement and I happen to be part of all the groups so technically I should get all the drive mappings, but what happens is that I'll only get the first match, which is the first drive mapping, is there something I'm missing?

IF INGROUP("MICRO EXCHANGE-FAD")
CALL "Micro Exchange.kix"
ENDIF

IF INGROUP("FTP Users")
CALL "FTP Users.kix"
ENDIF

IF INGROUP("AccessIMAGES-PPB")
CALL "IMAGES.kix"
ENDIF

Top
#37816 - 2003-03-12 04:54 PM Re: More than one IF INGROUP statement
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Welcome to the board.

The code you posted does not show us anything about mapping drives. It shows calling other scripts. We can not know what if these script exist, what should happen in the scripts, or if there are coding problems in them.

Please simply your test code to:
code:
IF INGROUP("MICRO EXCHANGE-FAD")
? "Member of group MICRO EXCHANGE-FAD"
ENDIF

IF INGROUP("FTP Users")
? "Member of group FTP Users"
ENDIF

IF INGROUP("AccessIMAGES-PPB")
? "Member of group AccessIMAGES-PPB"
ENDIF

in order to test your IF ingroup statements. Once they work to your satisfaction add in your additional code to map your drives.

Please also see: http://www.kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic;f=1;t=005181

Also search the board for other disscusion on using and troubleshooting "ingroup" issues.

[ 12. March 2003, 16:57: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#37817 - 2003-03-12 05:01 PM Re: More than one IF INGROUP statement
Tracy Offline
Fresh Scripter

Registered: 2003-03-12
Posts: 9
Sorry, this is the script that it calls, whether it be the Micro Exchange or FTP or the Images, the only thing that's different for all three is the share name at the bottom, which corresponds to the correct share name:

:SETVARIABLE
IF "%OS%" <> "Windows_NT" ; If WinNT, Winset Causes Dr. Watson
$WINVER = ReadValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion", "Version")
SHELL "WinSet.exe USERNAME=@USERID"
; "Setting more DOS variables..."
SHELL "Winset.exe ADDRESS=@ADDRESS"
SHELL "Winset.exe COMPUTER=@WKSTA"
SHELL "Winset.exe DOMAIN=@DOMAIN"
SHELL "Winset.exe COMMENT=@COMMENT"
SHELL "Winset.exe FULLNAME=@FULLNAME"
SHELL "Winset.exe HOMEDIR=@HOMEDIR"
SHELL "Winset.exe HOMESHR=@HOMESHR"
SHELL "Winset.exe LSERVER=@LSERVER"
SHELL "Winset.exe PRIV=@PRIV"
ENDIF
;
:MAP_DRIVES

use I: /delete
use I: \\HQNT11\HTDOCS

:END
SETTIME "@LSERVER" ; Set WS Time From Logon Server
CLS
QUIT

Top
#37818 - 2003-03-12 05:08 PM Re: More than one IF INGROUP statement
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Please take a look at the KiXtart Manual with regards to the correct syntax for KiXtart functions/commands!
code:
use I: /delete /persistent
use I: '\\HQNT11\HTDOCS'



[ 13. March 2003, 15:49: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
#37819 - 2003-03-12 05:09 PM Re: More than one IF INGROUP statement
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Have you read the manual and the differences between QUIT and EXIT?

You do not need to write a bunch of little scripts and call them for mapping drives. There is a time and place for using sub-scripts. This is not it.

Remove the QUIT from the bottom of scripts and see what happens.

[ 12. March 2003, 17:10: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#37820 - 2003-03-12 05:13 PM Re: More than one IF INGROUP statement
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Why are you using all the SHELL Winset statements?
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#37821 - 2003-03-12 05:29 PM Re: More than one IF INGROUP statement
Tracy Offline
Fresh Scripter

Registered: 2003-03-12
Posts: 9
Thanks for your help. Putting in the Exit is what I needed instead of the Quit. I did not write these scripts, we had a consultant in a few years ago when we migrated and this is all his writing. I am slowly learning what all the syntaxes are and yes, I am reading the manual, but you know when this is not something you do everyday, it takes time to learn and this is why we have these posts.

I have to use sub-scripts because there are many users in one group that may need a particular drive mapping, I'm not about to enter in a line for each user to set a drive mapping, if there is an easier way, I will find it, however, that will take me a little time to investigate as well.

The winset commands, I'm not sure why he had them in there, I will look into it.

Thanks again for your replies.

Top
#37822 - 2003-03-12 05:39 PM Re: More than one IF INGROUP statement
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
The WINSET commands were used in order to support Windows 9x. The latest version of KiXtart has fully Windows 9x-compliant SET commands.

You might want to investigate the use of a .INI file for more granular mappings or re-organizing the groups your users are members of.
_________________________
There are two types of vessels, submarines and targets.

Top
#37823 - 2003-03-13 02:18 PM Re: More than one IF INGROUP statement
maverick747 Offline
Lurker

Registered: 2003-03-13
Posts: 3
Hi!

I have the same problem as Tracy, and for some reason the problem in question doesn't seem quite understood.
I have users with membership in several usergroups in the domain (NT4.0), and each group are coupled to different sets of resources. A user who is member of several groups needs all the resouces ment for EACH AND EVERY group.

I have tried the same thing as Tracy; to list subsequent IF INGROUP (I used first CASE INGROUP, but got the same result)
in Tracy's example:

IF INGROUP("MICRO EXCHANGE-FAD")
CALL "Micro Exchange.kix"
ENDIF

IF INGROUP("FTP Users")
CALL "FTP Users.kix"
ENDIF

IF INGROUP("AccessIMAGES-PPB")
CALL "IMAGES.kix"
ENDIF

In this scenario, all the kix-scripts mentioned (Micro Exchange.kix, FTP Users.kix and IMAGES.kix) performs different commands, like drive mappings for example like this:

Micro Exchange.kix script read:
use k: "\\SERVER1\EXCHANGE"

FTP Users.kix script read:
use l: "\\SERVER1\FTP"

IMAGES.kix script read:
use m: "\\SERVER1\IMAGES"

And a user who is member in all groups needs, as I said above, ALL mappings.
The question is: IS IT POSSIBLE TO USE KIXTART TO ACHIEVE THIS?

As for Tracy, I get only the mapping from the first script specified (in this example the Micro Exchange.kix -script)

Howard Bullock says:
"You do not need to write a bunch of little scripts and call them for mapping drives. There is a time and place for using sub-scripts. This is not it."

If sub-scripts is not the way, then how? Having commands for all combinations of "user-needs" in the primary script would make a VERY long and complicated script.

Maverick747

Top
#37824 - 2003-03-13 02:43 PM Re: More than one IF INGROUP statement
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
the problem (I'm 97% sure) is that you don't specify the path to the script.
if the script resides in the same directory, try this syntax:
code:
IF INGROUP("AccessIMAGES-PPB")
CALL @scriptdir+"\IMAGES.kix"
ENDIF

_________________________
!

download KiXnet

Top
#37825 - 2003-03-13 02:52 PM Re: More than one IF INGROUP statement
Tracy Offline
Fresh Scripter

Registered: 2003-03-12
Posts: 9
Hi, it actually works for me now, in the sub script that I'm calling from my primary script, I had Quit instead of Exit as my last command, now all the drives get mapped.
Top
#37826 - 2003-03-13 03:53 PM Re: More than one IF INGROUP statement
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
It might be better to e.g. put all your mappings into a .INI file and have just one sections that processes all mappings at once. Example:
code:
; Mandatory drive shares for users
;
; Format:
;
;[UNC]
;Drive = drive letter to which the UNC name will be mapped, '*' is valid
;GroupInclude = User groups to be included in the drive share
;CompExclude = Computers to be excluded from the drive share (overrides GroupInclude)
;UserInclude = Users to be included in the drive share (overrides CompExclude)
;NetworkType = Type of network connection allowed for this share (LOCAL, LAN, VPN, DIALUP)
;Persistent = True if mapping is persistent
;DenyGuestAccess = True if guests are not allowed to access this share

[\\server\share]
Drive=L
GroupInclude=Domain Users, Domain Admins
CompExclude=JUKEBOX, LAPTOP1, WORKSTATION1
NetworkType=LOCAL, LAN, VPN, DIALUP
Persistent=1

_________________________
There are two types of vessels, submarines and targets.

Top
#37827 - 2003-03-14 02:07 PM Re: More than one IF INGROUP statement
maverick747 Offline
Lurker

Registered: 2003-03-13
Posts: 3
Thanks for answering, but the reason for my problem was me being stupid! [Frown]

I had copied a kix-script from someone else and used it as a template for my own scripts.
The mistake was that in the bottom of this script, just before EXIT, the following command was added:

:END

I cannot find the :END command in the KIX -reference /documentation, but still it seems that it makes the KIX-process stop (and don't return to the primary script to read subsequent IF INGROUP -commands).
SO IF YOU FIND ":END" -in your scripts and don't know exactly what it's doing there; REMOVE IT!

Also, the SELECT /CASE INGROUP / ENDSELECT also works the same way as IF INGROUP / ENDIF.
So, now I have successfully tested the following 2 options for running commands related to several group memberships (the * -lines are only used here to separate the different scripts):

Commands in the primary.kix -script:
******************************************

? Adding all network printers for all users
If ADDPRINTERCONNECTION ("\\server1\hp laserjet 4") = 0
If ADDPRINTERCONNECTION ("\\server1\hp lj4 serverroom") = 0
If ADDPRINTERCONNECTION ("\\server2\Colorprinter ") = 0
Endif

? Checking for group memberships in primary.kix
IF INGROUP("MICRO EXCHANGE-FAD")
CALL "Micro Exchange.kix"
ENDIF
IF INGROUP("FTP Users")
CALL "FTP Users.kix"
ENDIF
IF INGROUP("AccessIMAGES-PPB")
CALL "IMAGES.kix"
ENDIF

EXIT
***********************

or

***********************
? Adding all network printers for all users
If ADDPRINTERCONNECTION ("\\server1\hp laserjet 4") = 0
If ADDPRINTERCONNECTION ("\\server1\hp lj4 serverroom") = 0
If ADDPRINTERCONNECTION ("\\server2\Colorprinter ") = 0
Endif

Commands in the primary .kix -script:
SELECT
CASE INGROUP("MICRO EXCHANGE-FAD")
CALL "Micro Exchange.kix"
ENDSELECT
SELECT
CASE INGROUP("FTP Users")
CALL "FTP Users.kix"
ENDSELECT
SELECT
CASE INGROUP("AccessIMAGES-PPB")
CALL "IMAGES.kix"
ENDSELECT

EXIT
*********************

Commands in Micro Exchange.kix script read:
************************
? Map drives for the MICRO EXCHANGE-FAD group
use k: "\\SERVER1\EXCHANGE"

? Select default printer for the MICRO EXCHANGE-FAD group
If SetDefaultPrinter ("\\server1\hp laserjet 4") = 0
Endif

EXIT
************************

FTP Users.kix script read:
**************************
? Map drives for the FTP Users group
use l: "\\SERVER1\FTP"

? Select default printer for the FTP Users group
If SetDefaultPrinter ("\\server1\hp lj4 serverroom") = 0
Endif

EXIT
**************************

IMAGES.kix script read:
*****************************
? Map drives for the FTP Users group
use m: "\\SERVER1\IMAGES"

? Select default printer for the FTP Users group
If SetDefaultPrinter ("\\server2\Colorprinter") = 0
Endif

EXIT
***************************

Now a user who is member of all groups gets all drive mappings; k:, l: and m: (and the default printer from the first subscript)!

FINALLY A QUESTION TO SEALEOPARD:
If Im going to use an .INI -file, how should I call that file from a .KIX -script?

Top
#37828 - 2003-03-14 02:29 PM Re: More than one IF INGROUP statement
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Bad coding. Every IF needs its own ENDIF. You should not use IF to silence a return code. Use IF to recover from errors or to control script flow. Assign the return code to a var to silence.

[ 14. March 2003, 14:31: Message edited by: LLigetfa ]
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#37829 - 2003-03-14 03:08 PM Re: More than one IF INGROUP statement
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Please don't give incorrect advise!

The :END line in the script is a label. Labels are documented inthe KiXtart script and do not have any advers effects on sripts. They are legitimate KiXtart syntax.

Also, please adhere to ABC's of KiXtart board etiquette and message to new forum users by not hijacking other people's posts and by posating code in between [code] tags.

Re .INI files: You would use READPROFILESTRING() to read the sections, then the appropriate keys for each section. There have been a couple of examples posted with regards to using .INI files for printer/drive mappings.
_________________________
There are two types of vessels, submarines and targets.

Top
#37830 - 2003-03-14 04:58 PM Re: More than one IF INGROUP statement
maverick747 Offline
Lurker

Registered: 2003-03-13
Posts: 3
To Sealeopard:
1. What ever :END may be used as, when I removed it, my script worked like intended.
2. There is no hijacking or malicious code here, I only continued using Tracy's examples of groups and mappings. And I use specific examples (just like Tracy and yourself) deliberately and also tries to make them as complete as possible because that makes it easier for everyone to understand exactly what the situation / problem / solution is.
3. Thanks for your referance to the READPROFILESTRING -command. Have not tested it yet, but I think I understand how to use it toward .INI -files.

To LLigetfa:
Where is the bad coding? Where is the IF without its own ENDIF?

Keep smiling [Smile]

Top
#37831 - 2003-03-14 05:01 PM Re: More than one IF INGROUP statement
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
It's here:
code:
If ADDPRINTERCONNECTION ("\\server1\hp laserjet 4") = 0
If ADDPRINTERCONNECTION ("\\server1\hp lj4 serverroom") = 0
If ADDPRINTERCONNECTION ("\\server2\Colorprinter ") = 0
Endif

Three nested IFs with just one ENDIF. This will cause your script not to run correctly.
And your script did not run correctly because of removing :END.
_________________________
There are two types of vessels, submarines and targets.

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 823 anonymous users online.
Newest Members
JimDunn, fgarcia, Viginette, ManuvdWielNL, Sir_Barrington
17890 Registered Users

Generated in 0.109 seconds in which 0.065 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