Hi,

I use a script to map network drives. Now some users have problems with the mappings. The problem is that not all variables are used, so sometimes mappings point at the wrong share.

I've used a central script to start other scripts and load UDF's.

here's the important part:

 Code:
Break On 

;Declare global variables
Global $NetLogon, $LogFldr, $DFS
$NetLogon = "\\hollands-midden.local\netlogon\"
$LogFldr = "C:\Temp\"
$DFS = "\\RBHM\DFS"

;Load Functions
Call udf.kix

Call drives.kix



then there's the UDF's that are used (with thanks to Richard H.):
 Code:
;ShowStatus()
;Gives (error messages), use verbose 0 for errors only, verbose 1 for error and success messages and verbose 2 for success only
Function ShowStatus($sMessage, Optional $bVerbose)
	If @ERROR
		If $bVerbose <> 2
		"ERROR: "+$sMessage+@CRLF
		"Reason: ["+@ERROR+"] "+@SERROR+@CRLF
		EndIf
	Else
		If $bVerbose
			"SUCCESS: "+$sMessage+@CRLF 
		EndIf	
	EndIf	
Exit @ERROR
EndFunction

;MapDrv()
;Maps drive, deletes old mapping if necessary and gives detailed information if necessary
Function MapDrv($Drv, $Shr)
USE $Drv $DFS + $Shr
		ShowStatus("Mapping $Shr: ", 2)
	IF @ERROR <> 0
		USE $Drv /DELETE /PERSISTENT
		USE $Drv $DFS + $DataShr
		ShowStatus("Mapping $Shr: ", 1)
	ENDIF
EndFunction


and (a part of) the drives.kix file:

 Code:
Dim $HomeShr, $AppShr, $AfdShr

$HomeShr = "\Home" ;Leiden home share
$AppShr = "\Applicatie" ;Leiden Applicatie share
$AfdShr = "\Afdeling" ;Leiden Afdeling share

MapDrv("F:", $HomeShr)
MapDrv("I:", $AppShr)
MapDrv("J:", $AfdShr)


sometimes the script mappes all drives to \\RBHM\DFS.

any idea's? i'm kinda stunned...

regards,

Jeroen


Edited by Howard Bullock (2007-05-01 04:01 PM)
Edit Reason: Corrected code tags