#183144 - 2007-12-02 02:07 PM
Mapping takes awhile to error when path does not exist
|
_Andy_
Fresh Scripter
Registered: 2007-10-27
Posts: 17
Loc: Sydney, Australia
|
Hi All,
I have written a little function to help me map drives and just wondering if there was a way to speed up the error message when the unc path that I am trying to map to does not exist???
Function MapDrive($x_letter, $x_share, $x_user, $x_pass, $x_label )
dim $ip_arr
dim $regval
If $x_letter And $x_share
use $x_letter /DELETE
If $x_user
If $x_pass
use $x_letter $x_share /user:$x_user /password:$x_pass
Else
use $x_letter $x_share /user:$x_user
Endif
Else
use $x_letter $x_share
Endif
If @error <> 0
$x= Messagebox ("Unable to map drive - " + $x_letter + " to " + $x_share + @crlf + @crlf + "Processing will continue.","Error",48,500)
return
EndIf
If $x_label
$ip_arr = Split ($x_share, "\")
$regval = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2\##" + $ip_arr[2] + "#" + $ip_arr[3]
WriteValue($regval,"_LabelFromReg",$x_label,"REG_SZ")
Endif
Endif
EndFunction
Any help will be appreciated.
_________________________
Regards, Andy.
--Just shoot me, please.--
|
Top
|
|
|
|
#183208 - 2007-12-03 03:28 PM
Re: Mapping takes awhile to error when path does not exist
[Re: Richard H.]
|
Howard Bullock
KiX Supporter
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
A simpler approach to eliminate the delay of mapping drive for which shares do not exist and are not hidden would be to leverage the "Net View \\computer" command and wshpipe() the results into an array. You could check for the existance of the share prior to mapping the drive.
|
Top
|
|
|
|
#183210 - 2007-12-03 04:07 PM
Re: Mapping takes awhile to error when path does not exist
[Re: Howard Bullock]
|
Richard H.
Administrator
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
This is more about unreachable servers than missing shares.
Your proposal has merit though, as "net view" returns pretty quickly if the server cannot be found.
$sServerToPing="\\foobar"
Shell '"'+%COMSPEC%+'" /C net view '+$sServerToPing+' >nul: 2>nul:'
If @ERROR
"Net view failed - will not map shares"+@CRLF
Else
"Net view ok - will map shares"+@CRLF
EndIf
The port probe would be quicker, but the net view solution has the benefit that it doesn't require another tool to be installed.
|
Top
|
|
|
|
#183220 - 2007-12-03 09:40 PM
Re: Mapping takes awhile to error when path does not exist
[Re: NTDOC]
|
Howard Bullock
KiX Supporter
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
Doc, please elaborate why you would not provide the computer name. Just using "Net View" seems rather useless. I do not see how what you say would work for this situation.
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 507 anonymous users online.
|
|
|