Page 1 of 1 1
Topic Options
#119588 - 2004-05-14 05:28 PM If InGroup with 2 commands in it
alex13507 Offline
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 Offline
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 Offline
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
#119591 - 2004-05-14 06:04 PM Re: If InGroup with 2 commands in it
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
huh.
do you have multiple accounts?
your comments sound so similar to one post earlier today.

IF INGROUP("GROUP")
use k: /delete /persistent
use k: "\\SERVER\SHARE"
endif

is what you want and what is NEEDED for proper functionality.
if the problem persist with that line, it will be investigated, but it is the base.
_________________________
!

download KiXnet

Top
#119592 - 2004-05-14 06:08 PM Re: If InGroup with 2 commands in it
alex13507 Offline
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
#119593 - 2004-05-14 06:18 PM Re: If InGroup with 2 commands in it
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
ok, next thing.
if you look my previous code, you see that your code missed the quotes.

next thing to check is another DC's.
if you have multiple of them, check their logonscript folder and see they are synced.
_________________________
!

download KiXnet

Top
#119594 - 2004-05-14 07:55 PM Re: If InGroup with 2 commands in it
alex13507 Offline
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 Offline
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


_________________________
Home page: http://www.kixhelp.com/hb/

Top
#119596 - 2004-05-16 11:24 PM Re: If InGroup with 2 commands in it
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
hmm...
don't remember asking it yet.
what version of kix you are using?
_________________________
!

download KiXnet

Top
#119597 - 2004-05-17 02:37 PM Re: If InGroup with 2 commands in it
alex13507 Offline
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 Offline
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
#119599 - 2004-05-17 08:32 PM Re: If InGroup with 2 commands in it
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
you could also try with 4.22
also, make sure that you call the executable with full path.
this way no other version can be used.

why I say, is that there is bug fixed in use /del in 4.20 and in 4.22
so, if you have somewhere on your path 4.12 (as an example) you could be running to bug.
_________________________
!

download KiXnet

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
1 registered (Henriques) and 2516 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.068 seconds in which 0.031 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