Wolven
(Fresh Scripter)
2002-09-10 07:11 PM
InGroup (script only works for the very first group in the script)

Hey guys, I have generated a login script that takes advantage of the "InGroup" feature. But my login script only works for the very first group in the script. To get the script to map drives according to the group I have to move that group to the top of the script, subsequently the other group mappings fail. No error message.

Has anyone seen this before?

(MCA: extend subject)

[ 05. December 2002, 01:17: Message edited by: MCA ]


ShawnAdministrator
(KiX Supporter)
2002-09-10 07:17 PM
Re: InGroup (script only works for the very first group in the script)

Wolven,

Are you using CASE statements ... or IF statements ? Might want to post a little snippet of code on this one.


Wolven
(Fresh Scripter)
2002-09-10 07:18 PM
Re: InGroup (script only works for the very first group in the script)

Additional Information: Windows NT environment, Clients are 9x-2k. The script is simply exiting before the entire script has run.

Wolven
(Fresh Scripter)
2002-09-10 07:21 PM
Re: InGroup (script only works for the very first group in the script)

Thanks for the response Shawn. Just using the "IF" statement. Here is a sample of my code:

code:
$Drive="f"
$Share="\\darla\statements"

If InGroup (HOUBANK)

If InGroup ("HOUBANK")
? "Mapping drive $Drive to $Share"
Use "$Drive:" /Delete
Use "$Drive:" $Share
If @error = 0
? " Map Successful"
eLSE
? " Error mapping drive $Drive to $Share"
EndIf

$Drive="j"
$Share="\\darla\HOUBANK"

If InGroup ("HOUBANK")
? "Mapping drive $Drive to $Share"
Use "$Drive:" /Delete
Use "$Drive:" $Share
If @error = 0
? " Map Successful"
eLSE
? " Error mapping drive $Drive to $Share"
EndIf

$Drive="r"
$Share="\\buckwheat\ri"

If InGroup ("HOUBANK")
? "Mapping drive $Drive to $Share"
Use "$Drive:" /Delete
Use "$Drive:" $Share
If @error = 0
? " Map Successful"
eLSE
? " Error mapping drive $Drive to $Share"
EndIf

$Drive="f"
$SHARE="\\darla\statements"

If InGroup (Accounting)

; input time synchronization command
If InGroup("accounting")
? "Mapping drive $Drive to $Share"
Use "$Drive:" /Delete
Use "$Drive:" $Share
If @error = 0
? " Map Successful"
eLSE
? " Error mapping drive $Drive to $Share"
EndIf

$Drive="k"
$Share="\\darla\cos"

If InGroup("accounting")
? "Mapping drive $Drive to $Share"
Use "$Drive:" /Delete
Use "$Drive:" $Share
If @error = 0
? " Map Successful"
eLSE
? " Error mapping drive $Drive to $Share"
EndIf

$Drive="l"
$Share="\\darla\data"

If InGroup("accounting")
? "Mapping drive $Drive to $Share"
Use "$Drive:" /Delete
Use "$Drive:" $Share
If @error = 0
? " Map Successful"
eLSE
? " Error mapping drive $Drive to $Share"
EndIf

$Drive="s"
$Share="\\stymie\Program Files"

If InGroup("accounting")
? "Mapping drive $Drive to $Share"
Use "$Drive:" /Delete
Use "$Drive:" $Share
If @error = 0
? " Map Successful"
eLSE
? " Error mapping drive $Drive to $Share"
EndIf

This is replicated on down for each department respectively.

Thanks for the help

(MCA: correct layout)

[ 05. December 2002, 01:20: Message edited by: MCA ]


Sealeopard
(KiX Master)
2002-09-10 07:27 PM
Re: InGroup (script only works for the very first group in the script)

You are missing a couple of ENDIF. Each IF requires a corresponding ENDIF. Please see the KiXtart Manual for correct IF-ENDIF syntax.

Example
code:
$Drive='S'
$Share='\\stymie\Program Files'

If InGroup('accounting')
? 'Mapping drive '+$Drive+' to '+$Share
USE $Drive+':' /Delete
USE $Drive+':' $Share
IF @ERROR
? ' Error mapping drive '+$Drive+' to '+$Share
ELSE
? ' Map Successful'
ENDIF
ENDIF



Wolven
(Fresh Scripter)
2002-09-10 07:46 PM
Re: InGroup (script only works for the very first group in the script)

Thanks for the input Sealeopold, I tried your suggestions and I get the same result. KIX2001.DOC, Kixtart.chm have very limited information on the "InGroup" feature from what I could search on. Bear in mind, that if I move any of the groups my test user is a member of to the top of the script then the drive mappings will work.

Thanks.


Sealeopard
(KiX Master)
2002-09-10 07:51 PM
Re: InGroup (script only works for the very first group in the script)

Have you added all of the missing ENDIFs? Run your script through KiXXStrip ( http://home.wanadoo.nl/scripting ) to check the syntax. Also, have you refreshed the token cache for KiXtart?

Wolven
(Fresh Scripter)
2002-09-10 09:21 PM
Re: InGroup (script only works for the very first group in the script)

Hey Thanks to you both, I figured it out from both of your inputs. Correct Syntax below:
code:
SELECT
CASE InGroup("Group")
$Drive="drive letter"
$SHARE="\\servername\share"
? "Mapping drive $Drive to $Share"
Use "$Drive:" /Delete
Use "$Drive:" $Share
If @error = 0
? " Map Successful"
eLSE
? " Error mapping drive $Drive to $Share"
EndIF

$Drive="drive letter"
$Share="\\servername\share"
? "Mapping drive $Drive to $Share"
Use "$Drive:" /Delete
Use "$Drive:" $Share
If @error = 0
? " Map Successful"
eLSE
? " Error mapping drive $Drive to $Share"
EndIF
ENDSELECT

FYI for other novices; Each "GROUP" must have only a single CASE statement following the SELECT statemet with all the subsequent drive mappings underneath. Only use the "ENDSELECT" statement at the very end of your script.

Once Again, Thanks to All!

{edit} Bullock - added code tags.

[ 10. September 2002, 21:35: Message edited by: Howard Bullock ]


Howard Bullock
(KiX Supporter)
2002-09-10 09:41 PM
Re: InGroup (script only works for the very first group in the script)

Wolven, for a script that maps multiple drives, you may want to investigate a UDF to make adding mappings easier.

MapDrive("h:", "MyFileServer", "MyShareName")

code:
Function MapDrive($Drive, $Server, $Share)
Dim $Drive, $Server, $Share
Color c+/n
If $Drive<>"" and $Server<>"" and $Share<>""
$LogText="Connecting $Drive to \\$Server\$Share"
? $LogText
USE $Drive /Delete /Persistent
USE $Drive "\\$Server\$Share"
If @error=0
color g+/n
$x=" - Success"
"$x"
Else
color r+/n
$x=" - Failed: Error @error"
"$x"
$ErrorState=1
Endif
;WriteLog ($LogText + $x) ;UDF in UDF Library
Color w+/n
Else
;UDF in UDF Library
;WriteLog ("Function 'MapDrive' called with invalid parameters: '$Drive', '$Server', '$Share'")
Endif
Endfunction



Sealeopard
(KiX Master)
2002-09-10 10:10 PM
Re: InGroup (script only works for the very first group in the script)

You should also be aware that SELECT-CASE-ENDSELECT will only process the first TRUE evaluation. Therefore, if a user is a member of multiple groups, it'll process only the first group. Also, CASE accepts any logical validation, thus you can combine multiple conditions with AND/OR.

MCA
(KiX Supporter)
2002-12-05 01:16 AM
Re: InGroup (script only works for the very first group in the script)

Dear,

With our tool kixstrip you can verify your script.
With the call
kixstrip input.kix output.kix /block_check
we get
code:
 $drive="f"
$share="\\darla\statements"

IF InGroup (houbank)

IF InGroup ("HOUBANK")
? "Mapping drive $Drive to $Share"
USE "$Drive:" /delete
USE "$Drive:" $share
IF @error = 0
? " Map Successful"
ELSE
? " Error mapping drive $Drive to $Share"
ENDIF

$drive="j"
$share="\\darla\HOUBANK"

IF InGroup ("HOUBANK")
? "Mapping drive $Drive to $Share"
USE "$Drive:" /delete
USE "$Drive:" $share
IF @error = 0
? " Map Successful"
ELSE
? " Error mapping drive $Drive to $Share"
ENDIF

$drive="r"
$share="\\buckwheat\ri"

IF InGroup ("HOUBANK")
? "Mapping drive $Drive to $Share"
USE "$Drive:" /delete
USE "$Drive:" $share
IF @error = 0
? " Map Successful"
ELSE
? " Error mapping drive $Drive to $Share"
ENDIF

$drive="f"
$share="\\darla\statements"

IF InGroup (accounting)

; input time synchronization command
IF InGroup("accounting")
? "Mapping drive $Drive to $Share"
USE "$Drive:" /delete
USE "$Drive:" $share
IF @error = 0
? " Map Successful"
ELSE
? " Error mapping drive $Drive to $Share"
ENDIF

$drive="k"
$share="\\darla\cos"

IF InGroup("accounting")
? "Mapping drive $Drive to $Share"
USE "$Drive:" /delete
USE "$Drive:" $share
IF @error = 0
? " Map Successful"
ELSE
? " Error mapping drive $Drive to $Share"
ENDIF

$drive="l"
$share="\\darla\data"

IF InGroup("accounting")
? "Mapping drive $Drive to $Share"
USE "$Drive:" /delete
USE "$Drive:" $share
IF @error = 0
? " Map Successful"
ELSE
? " Error mapping drive $Drive to $Share"
ENDIF

$drive="s"
$share="\\stymie\Program Files"

IF InGroup("accounting")
? "Mapping drive $Drive to $Share"
USE "$Drive:" /delete
USE "$Drive:" $share
IF @error = 0
? " Map Successful"
ELSE
? " Error mapping drive $Drive to $Share"
ENDIF

;($begin)
;
; thu 05-dec-2002 01:17:51 (kix 4.10 vs 3.20e)
;
;Informative KIXSTRIP: input=95 output=95 skip=0
;
;Warning KIXSTRIP: 9 errors in block structure(s). missing statement(s).
; - do:until [0:0]
; - for|each:in|to:step|next [0|0:0|0:0|0]
; - function:endfunction [0:0]
; -ERROR- - if:else:endif [16:7:7]
; - select:case:endselect [0:0:0]
; - while:loop [0:0]
;Warning KIXSTRIP: some lines contains errors or possible errors.
;Informative KIXSTRIP: 16 block_structures found.
;Informative KIXSTRIP: no UDF's found.
;Informative KIXSTRIP: no labels found.
;Summary KIXSTRIP: BREAK CALL DEBUG DISPLAY ENDFUNCTION EXECUTE EXIT FUNCTION GET GETS GOSUB GOTO OLExxx PLAY QUIT RETURN RUN SHELL SLEEP THEN USE
;Informative KIXSTRIP: 14 USE
;
;($end)
;($begin)
;
;
;($end)

greetings.


LonkeroAdministrator
(KiX Master Guru)
2002-12-05 01:20 AM
Re: InGroup (script only works for the very first group in the script)

couldn't find any older post [Eek!]

wow, you must be really digging as there has been at least 1000 topics after this... huh.


MCA
(KiX Supporter)
2002-12-05 01:47 AM
Re: InGroup (script only works for the very first group in the script)

Dear Lonkero,

For us it is very easy to find an older one. Examples of them are F1-1 and F2-1.
Only we are searching at this moment for topics, which doesn't have all answers for
the question in it and which answer can more complete with additional information.
In this case readers/members doesn't need first to download our tool to see
possibilities.
greetings.
greetings.


LonkeroAdministrator
(KiX Master Guru)
2002-12-05 01:50 AM
Re: InGroup (script only works for the very first group in the script)

yeah, but still the search for such an topic without "good" result is manual job.

cheers
cheers [Wink]