Page 1 of 2 12>
Topic Options
#183144 - 07/12/02 02:07 PM Mapping takes awhile to error when path does not exist
_Andy_ Offline
Fresh Scripter

Registered: 07/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???

 Code:
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
#183145 - 07/12/02 02:16 PM Re: Mapping takes awhile to error when path does not exist [Re: _Andy_]
Les Offline
KiX Master
*****

Registered: 01/06/11
Posts: 12734
Loc: fortfrances.on.ca
This has been discussed before. THe delay is an OS thing, not KiX so there is no tweaking KiX. That said, ping the box hosting the share. Not a complete solution cuz ping does not assure the share is available.

Why would you be mapping to an unreliable box hosting a share?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#183146 - 07/12/02 02:19 PM Re: Mapping takes awhile to error when path does not exist [Re: Les]
Arend_ Moderator Offline
MM club member
*****

Registered: 05/01/17
Posts: 1792
Loc: Hilversum, The Netherlands
To speed things up a little, use fully qualified DNS names or IP addresses of the hosts you are trying to map to.
Top
#183147 - 07/12/02 02:37 PM Re: Mapping takes awhile to error when path does not exist [Re: Arend_]
_Andy_ Offline
Fresh Scripter

Registered: 07/10/27
Posts: 17
Loc: Sydney, Australia
Hi Les,
I did a search for this beforehand but obviously I did not spend hours looking for it. Maybe I will try the shout box first next time to see if an item is listed (and hope that I do not get flamed to death).

As I and my workmates travel to many client sites, I have started to build up a collection of drive mapping details and am in the process of writing and ini file with kix script combo to store, retrieve and run my required mappings.

Sometimes I click the wrong one... and whack me with a #$%#$% huge stick, the wait time kills me, especially if I am in a hurry (all the time) and if someone is standing right behind me (most of the time)........

I thought of ping but some sites I visit have disabled ping in their networks - a fear of internal hackers...
_________________________
Regards,
Andy.


--Just shoot me, please.--

Top
#183148 - 07/12/02 02:44 PM Re: Mapping takes awhile to error when path does not exist [Re: _Andy_]
Les Offline
KiX Master
*****

Registered: 01/06/11
Posts: 12734
Loc: fortfrances.on.ca
_Andy_,
I'm not flaming you for not searching. You are more likely to be flamed if you try to "shop talk" in the shout box.

If this mapping is not for the general user, then you're forgiven. \:D

What you can do is put some sanity checks in your script. For example, if you have a mapping script for a particular site, you can check your own IP and only do the mapping if you are in that site's IP scope.

As I said, the delay is an OS thing and cannot be changed.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#183176 - 07/12/03 12:54 AM Re: Mapping takes awhile to error when path does not exist [Re: Les]
_Andy_ Offline
Fresh Scripter

Registered: 07/10/27
Posts: 17
Loc: Sydney, Australia
Thanks Les.

Yes, this is script is not for general users.
The ip scope will work for about half, so I will incorporate that into my script.

Thanks again \:\)
_________________________
Regards,
Andy.


--Just shoot me, please.--

Top
#183178 - 07/12/03 01:00 AM Re: Mapping takes awhile to error when path does not exist [Re: _Andy_]
NTDOC Administrator Offline
Administrator
*****

Registered: 00/07/28
Posts: 11540
Loc: CA
Ping the machine first.
If ping is good then check for a flag file on the share
If good THEN map the drive.

Top
#183180 - 07/12/03 01:12 AM Re: Mapping takes awhile to error when path does not exist [Re: NTDOC]
Les Offline
KiX Master
*****

Registered: 01/06/11
Posts: 12734
Loc: fortfrances.on.ca
I'm guessing you missed that part
 Originally Posted By: _Andy_
I thought of ping but some sites I visit have disabled ping in their networks - a fear of internal hackers...
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#183184 - 07/12/03 05:26 AM Re: Mapping takes awhile to error when path does not exist [Re: Les]
NTDOC Administrator Offline
Administrator
*****

Registered: 00/07/28
Posts: 11540
Loc: CA
Some does not mean ALL and if you think you're ever going to have a "solution" that works on EVERY site then one needs to wake up from their dream state.

I saw it and I still think it should be part of the process for those that do allow it. For those that don't then he'll need to come up with another method or live with the potential slow mapping.

Top
#183190 - 07/12/03 09:16 AM Re: Mapping takes awhile to error when path does not exist [Re: NTDOC]
_Andy_ Offline
Fresh Scripter

Registered: 07/10/27
Posts: 17
Loc: Sydney, Australia
Ok, Ok... I will add the ping check too. For the sites that I know support ping I will store a ping_check parameter holding the ip address to check, if the field is blank, then the check will be skipped.

Thanks guys.
_________________________
Regards,
Andy.


--Just shoot me, please.--

Top
#183191 - 07/12/03 09:26 AM Re: Mapping takes awhile to error when path does not exist [Re: _Andy_]
Richard H. Administrator Offline
Administrator
*****

Registered: 00/01/24
Posts: 4945
Loc: Leatherhead, Surrey, UK
If ping is blocked on some sites then a robust check is to use tool to check for open ports - I'd use something like nmap as I'm familiar with it though it might be a little over-featured for this task.

You can use nmap to probe the target machine(s) for open NetBIOS ports. This sort of probe *has* to be allowed, otherwise you would not be able to map the drives anyway.

Just set the ports-to-scan to a single port used for CIFS shares and set the timeouts to a low enough level so you are not waiting for the probe to complete.

Top
#183208 - 07/12/03 03:28 PM Re: Mapping takes awhile to error when path does not exist [Re: Richard H.]
Howard Bullock Offline
KiX Supporter
*****

Registered: 00/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.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#183210 - 07/12/03 04:07 PM Re: Mapping takes awhile to error when path does not exist [Re: Howard Bullock]
Richard H. Administrator Offline
Administrator
*****

Registered: 00/01/24
Posts: 4945
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.
 Code:
$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
#183218 - 07/12/03 09:29 PM Re: Mapping takes awhile to error when path does not exist [Re: Richard H.]
NTDOC Administrator Offline
Administrator
*****

Registered: 00/07/28
Posts: 11540
Loc: CA
Just a minor note that NET VIEW does not require the UNC of the server to check the share names.
Only required if you want to map or start the share.

Top
#183220 - 07/12/03 09:40 PM Re: Mapping takes awhile to error when path does not exist [Re: NTDOC]
Howard Bullock Offline
KiX Supporter
*****

Registered: 00/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.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#183223 - 07/12/03 10:02 PM Re: Mapping takes awhile to error when path does not exist [Re: Howard Bullock]
NTDOC Administrator Offline
Administrator
*****

Registered: 00/07/28
Posts: 11540
Loc: CA
I didn't say I wouldn't use the computer name. I said you don't need to use the UNC


i.e. NET VIEW SERVER1

Instead of NET VIEW \\SERVER1

Top
#183225 - 07/12/03 10:08 PM Re: Mapping takes awhile to error when path does not exist [Re: NTDOC]
Howard Bullock Offline
KiX Supporter
*****

Registered: 00/09/15
Posts: 5809
Loc: Harrisburg, PA USA
Hmmm...

you learn something everyday.


I would never have tried that based on the internal docs:

 Quote:
NET VIEW
[\\computername [/CACHE] | /DOMAIN[:domainname]]
NET VIEW /NETWORK:NW [\\computername]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#183229 - 07/12/03 10:30 PM Re: Mapping takes awhile to error when path does not exist [Re: Howard Bullock]
NTDOC Administrator Offline
Administrator
*****

Registered: 00/07/28
Posts: 11540
Loc: CA
Agree. I found it by accident a while back.
Top
#183232 - 07/12/03 11:00 PM Re: Mapping takes awhile to error when path does not exist [Re: NTDOC]
Les Offline
KiX Master
*****

Registered: 01/06/11
Posts: 12734
Loc: fortfrances.on.ca
So, what if any advantage is there in leaving off the two hacks besides the obvious golf score?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#183240 - 07/12/04 01:07 AM Re: Mapping takes awhile to error when path does not exist [Re: Les]
NTDOC Administrator Offline
Administrator
*****

Registered: 00/07/28
Posts: 11540
Loc: CA
No real advantage per say. Just maybe when in a DOS console typing away.


Top
Page 1 of 2 12>


Moderator:  Jochen, Allen, Radimus, Chris S., Glenn Barnas, ShaneEP, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 72 anonymous users online.
Newest Members
FredR, jhirche, MarcSant, Daniel_9_jr, Ralf_Mueller
17368 Registered Users

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

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