#119588 - 2004-05-14 05:28 PM
If InGroup with 2 commands in it
|
alex13507
Fresh Scripter
Registered: 2002-04-26
Posts: 12
|
This works for me just fine:
IF INGROUP("GROUP") use k: \\SERVER\SHARE endif
If I change the server or share name, it will not override the users setting the next time they log in, and will have the old setting still.
My best idea on fixing this was to have a "use k: /delete" right before it maps it, but I can't get it to work. In my case, what would be the correct formatting?
I've tried many varients of the lines below, but none of them work
IF INGROUP("GROUP") use k: /delete use k: \\SERVER\SHARE endif
Thanks for any help!
|
|
Top
|
|
|
|
#119589 - 2004-05-14 05:42 PM
Re: If InGroup with 2 commands in it
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Use the "/PERSISTENT" switch on the delete - this will often help.
You should also check the result of the add and delete (see the @ERROR and @SERROR macros). If @ERROR is not zero, print the values out - this will give you a clue why the add or delete has failed.
Just follow each of the USE commands with something like: Code:
If @ERROR "Error deleting mapping: " @ERROR "/" @SERROR ? EndIf
|
|
Top
|
|
|
|
#119590 - 2004-05-14 06:00 PM
Re: If InGroup with 2 commands in it
|
alex13507
Fresh Scripter
Registered: 2002-04-26
Posts: 12
|
I tried /persistent on the /delete line, but no dice. I also added the error lines in, but they produce nothing. I used it in debug mode, and it works fine. I'm guessing the problem is that it can't delete the drive fast enough to have it remapped on the line below???
|
|
Top
|
|
|
|
#119592 - 2004-05-14 06:08 PM
Re: If InGroup with 2 commands in it
|
alex13507
Fresh Scripter
Registered: 2002-04-26
Posts: 12
|
Unfortunatley, this does not work for me... see my previous reply
and no, I don't have another account... sorry if it seems to be a repeat
|
|
Top
|
|
|
|
#119594 - 2004-05-14 07:55 PM
Re: If InGroup with 2 commands in it
|
alex13507
Fresh Scripter
Registered: 2002-04-26
Posts: 12
|
I do actually use " around the share ("\\server\share"), but it seems to work fine with or with out it. Sorry I didn't show that in my original message. It's when I add the /delete line in that doesn't seem to work. Like I said, it does work just fine in debug mode (with no persistent switch), which steps it through one by one.
I also am testing this locally, so no DC's to worry about.
I can have just one line in the middle of the if statement, and either the delete or mapping works fine, it's just they won't work together.
Hope that info helps, and thanks for all your help with this so far!
|
|
Top
|
|
|
|
#119595 - 2004-05-14 09:20 PM
Re: If InGroup with 2 commands in it
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
Try my UDF. I know this code is solid. Does it work?
for testing purposes you will need to comment out the logging lines or load the UDFs (available in the UDF Library.)
What is the LogonDomain? Is it the same domain as the group? Is this a domain global group? Did you try "domain\group"?
Code:
if INGROUP("GROUP") ? "LogonDomain: @Ldomain + " User: " + @userid + " is in group" MapDrive ("K:", "server", "share") else ? LogonDomain: @Ldomain + " User: " + @userid + " is NOT in group" endif
Function MapDrive($Drive, $Server, $Share) Dim $Drive, $Server, $Share, $shell 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" If val($DOS) >= 5 $shell=createobject("shell.application") $shell.namespace($Drive+"\").self.name=$Share + " on '" + $Server + "'" $shell = 0 Endif Else color r+/n $x=" - Failed: Error @error" "$x" $ErrorState=1 Endif WriteLog ($LogText + $x) WriteLog2("%temp%\MapDrive.log",$LogText + $x,1) Color w+/n Else WriteLog ("Function 'MapDrive' called with invalid parameters: '$Drive', '$Server', '$Share'") Endif Endfunction
|
|
Top
|
|
|
|
#119597 - 2004-05-17 02:37 PM
Re: If InGroup with 2 commands in it
|
alex13507
Fresh Scripter
Registered: 2002-04-26
Posts: 12
|
little behind with version 4.21
|
|
Top
|
|
|
|
#119598 - 2004-05-17 05:49 PM
Re: If InGroup with 2 commands in it
|
alex13507
Fresh Scripter
Registered: 2002-04-26
Posts: 12
|
thanks for all the help, but I finally found the sleep command, so throwing in a "sleep 1" between the delete and map commands works like a champ!
Thanks again
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
1 registered
(Henriques)
and 2516 anonymous users online.
|
|
|