Hmmm. Not sure.
The following construct should work, just fill in the correct details. I'm assuming you get an "access denied" (error 5) due to incorrect credentials, but I can't test here so you may need to change it.
code:
$iAccessDenied=5 ; Change to correct error message.
$iConnectAttempts=3 ; Number of times to attempt connection
$sSharePath="\\server\shares" ; Path to share
$sDriveToMap="X:"
Use $sDriveToMap /delete /persistent
Use $sDriveToMap $sSharePath
While @ERROR=$iAccessDenied AND $iConnectAttempts
$iConnectAttempts=$iConnectAttempts-1
"Enter login: " Gets $sLogin
"Enter Password: " Color "n/n" Gets $sPassword Color "w/n"
If Not $sLogin $sLogin=@USERID EndIF
Use $sDriveToMap $sSharePath /USER:$sLogin /PASSWORD:$sPassword
Loop
If @ERROR
"FATAL: Could not map "+$sSharePath+", last error="+@SERROR ?
EndIf
This scriptlet attempts to map the drive with current credentials, and if it fails due to access denied it will then prompt 2 or three times for login and password then use those. If it fails all attempts or if the connection fails for another reason it displays the last error.