Page 1 of 1 1
Topic Options
#197864 - 2010-02-24 04:22 PM Still cannot delete mapped drives and remap properly
MarkMelanson Offline
Fresh Scripter

Registered: 2006-10-09
Posts: 24
I have gone through all the articles and still cannot get this to work consistently using v4.60.

To Test:
I logon
I map a drive manually (persistent) to the wrong share
I run USE $Letter /delete /persistent
I run USE $Letter \\Server\Share

When I run it this way the drive does get deleted but it does not get re-mapped to the new share.

When I run it via the logon script it does not appear to anything at all. The share does not change. If I run NET USE instead it works fine except users see the CMD.EXE Run from UNC error. I don't mind utilizing NET USE if I can hide the error. I have not had any success with that either.

I hope I am just doing something silly. Is there a working UDF I could use instead?

Below is what I am currently using in the logon script:
 Code:
Function MapDrive($DriveLetter, $UNC, optional $persistent)
	dim $subcmd, $pt, $d, $di, $shell, $per
	? "Connecting " + $DriveLetter + " to " + $UNC
	$Ltr = Split($DriveLetter, ":")
	If exist($DriveLetter + '\')
;		shell "%ComSpec% /c net use " + $DriveLetter + " /delete /y> NUL 2>&1"
		USE $DriveLetter /delete /persistent
	EndIf
	If $persistent
		  use $DriveLetter $UNC /persistent
	Else
		  use $DriveLetter $UNC
	EndIf
	If not exist($DriveLetter + '\')
		$strDrvMapLog = "\\Server\logs$\DrvMapFailure\" + @WKSTA + ".TXT"
		WriteLog($strPrnMapLog, @DATE + "," + @TIME + "," + @WKSTA + "," + @UserID + "," + $DriveLetter + "," + $grplist)
		CLS
		" "
		? "COULD NOT MAP DRIVE "  + $DriveLetter + " to " $UNC + @CRLF
		? "Please contact the ServiceDesk at (XXX)XXX-XXXX for assistance." + @CRLF
		? "Press any key to continue..." get$
		exit 1
		return
	Endif
ENDFUNCTION

Top
#197867 - 2010-02-24 05:21 PM Re: Still cannot delete mapped drives and remap properly [Re: MarkMelanson]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
Just a couple of suggestions...

Try Kix 4.61 if at all possible. 4.60 has had its issues. I feel pretty confident you could replace the exe with little to no testing.

I can think of very few times when the persistent switch is really needed. You might try it without, and many of these problems would disappear.

Is your script running as a logon script or GPO/Startup Script?

Top
#197870 - 2010-02-24 06:21 PM Re: Still cannot delete mapped drives and remap properly [Re: Allen]
MarkMelanson Offline
Fresh Scripter

Registered: 2006-10-09
Posts: 24
Logon script. I will look at 4.61 but my script had issues with it (I did not investigate, I will now).

Thanks

Top
#197871 - 2010-02-24 07:14 PM Re: Still cannot delete mapped drives and remap properly [Re: MarkMelanson]
MarkMelanson Offline
Fresh Scripter

Registered: 2006-10-09
Posts: 24
v4.61 did not help but I did the NET USE error to output to nothingness.


change "> NUL 2>&1"
to "2>NUL >NUL"

Top
#197873 - 2010-02-24 07:53 PM Re: Still cannot delete mapped drives and remap properly [Re: MarkMelanson]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
Try "2>&1>NUL:" - this always works for me. Sends the STDERR stream to STDOUT before redirecting STDOUT.

I've pretty much moved from SHELL to WshPipe to execute any external commands. The version on my web site is just a tad different than what's posted here, as it returns the STDOUT and STDERR in separate arrays instead of mashing the output together. All output is masked that way, and no dealing with funky intermediate files to capture output.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#197879 - 2010-02-25 01:24 PM Re: Still cannot delete mapped drives and remap properly [Re: Glenn Barnas]
MarkMelanson Offline
Fresh Scripter

Registered: 2006-10-09
Posts: 24
Thanks Glenn. My DOS skills are getting rusty. :-)
Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 533 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.074 seconds in which 0.012 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org