#37815 - 2003-03-12 04:45 PM
More than one IF INGROUP statement
|
Tracy
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
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 ]
|
|
Top
|
|
|
|
#37817 - 2003-03-12 05:01 PM
Re: More than one IF INGROUP statement
|
Tracy
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
|
|
|
|
#37819 - 2003-03-12 05:09 PM
Re: More than one IF INGROUP statement
|
Howard Bullock
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 ]
|
|
Top
|
|
|
|
#37820 - 2003-03-12 05:13 PM
Re: More than one IF INGROUP statement
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
Why are you using all the SHELL Winset statements?
|
|
Top
|
|
|
|
#37821 - 2003-03-12 05:29 PM
Re: More than one IF INGROUP statement
|
Tracy
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
|
|
|
|
#37823 - 2003-03-13 02:18 PM
Re: More than one IF INGROUP statement
|
maverick747
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
|
|
|
|
#37825 - 2003-03-13 02:52 PM
Re: More than one IF INGROUP statement
|
Tracy
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
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
Lurker
Registered: 2003-03-13
Posts: 3
|
Thanks for answering, but the reason for my problem was me being stupid!
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
|
|
|
|
#37830 - 2003-03-14 04:58 PM
Re: More than one IF INGROUP statement
|
maverick747
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
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 735 anonymous users online.
|
|
|