C_LONGINT($0)

$0:=1


C_TEXT($1;$T_Server_path)  // Path of the folder to be mounted

$T_Server_path:=$1

C_TEXT($2;$T_User)  // Server authenticates  domain\\username or username@domain

$T_User:=$2

C_TEXT($3;$T_PW)

$T_PW:=$3

C_TEXT($4;$T_Lettre_Drive)

$T_Lettre_Drive:=$4


If (Count parameters=5)

C_POINTER($5;$P_Message)

$P_Message:=$5

End if 


$T_Lettre_Drive:=Uppercase($T_Lettre_Drive)


C_BOOLEAN($B_Drive)

$B_Drive:=(Character code($T_Lettre_Drive)>=65) & (Character code($T_Lettre_Drive)<=90)

ASSERT($B_Drive;"Wrong letter for the drive")

$T_Lettre_Drive:=Replace string($T_Lettre_Drive;":";"")

$T_Lettre_Drive:=$T_Lettre_Drive+":"


ASSERT(Length($T_Server_path)>0;"Path to volume is empty")

While ($T_Server_path[[1]]="\\")

$T_Server_path:=Substring($T_Server_path;2)

End while 


If (Test path name($T_Lettre_Drive)#Is a folder)


C_TEXT($T_LEP;$T_Auth)

$T_Auth:=Choose($T_User#"";" /user:"+$T_User+" "+$T_PW;"")

$T_LEP:="net use "+$T_Lettre_Drive+" \\\\"+$T_Server_path+$T_Auth


C_TEXT($in;$out;$error)

$in:=""

SET ENVIRONMENT VARIABLE("_4D_OPTION_HIDE_CONSOLE";"true")

LAUNCH EXTERNAL PROCESS($T_LEP;$in;$out;$error)


If (Not(Nil($P_Message)))

$P_Message->:="OUT: "+$out+" ERROR: "+$error

End if 


$0:=OK

End if