Sign in to follow this  
Followers 0
bluespirit

Invalid UNC path freezes scripts

4 posts in this topic

Hi,

I'm writing a script to copy a number of files from UNC paths. That bit is pretty simple. However, my users think my script has crashed, which it hasn't, it's only because the UNC path doesn't exist and one of the AutoIt functions is waiting. This is true of FileExists(), FileCopy(), DriveStatus(), etc.

Is there a function to check if a UNC path exists that doesn't pause in this fashion?

The only way round it, that I can think of at the moment, is to spawn another process and pre-check all the UNC paths and write if they exist in a text file. Then rather than use FileExists(), I use my text file instead.

Anybody got a better idea?

Thanks,

James

Share this post


Link to post
Share on other sites



You're are not in a domain, are you? I doubt pre-checking things would make the whole process more responsive.

The problem is probably not linked to AutoIt but instead has its root in how a peer LAN (without a domain) works. I guess your script is not hung, and that the AutoIt functions (which are likely more or less simple wrappers around Windows calls) are simply waiting for Windows function to return.

I've had a number of such irritrations when Windows decides that there is no more a Master Browser (Google for that) and it has to proceed to a Master Browser election. In MS parlance that means _almost_ locating a PDF (virtual to save trees) printer, print election bulletins, distribute them to the whole network where some computers can be badly drunk and sleeping hard, wait for the election results, proclaim the new King lound and pass the LAN crown to the newly elected Master Browser, which can only then decide which address the server you request has...

Of course all of this takes time, but I'm not sure that AutoIt is to blame here. There are many more details hidden, like the use of LMHOST defs, and more.

BTW, most MS peer LANs work without Master Browser, which is something I find funny. I may be off somewhere in the above pseudo-rationale but the only thing to know is that a MS peer LAN can take much time to answer initial request on/for a given server. This is part of a long tradition of MS network protocols to be unreliable, slow, ineffective and completely off any standard. But as a long-term Windows users you and me now have some hard time finding that abnormal :)

Of course, enterprise networks don't work this way!


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

Funny you should mention enterprise domains as that is what the script is running on. All the valid UNC paths return immediately. It's the invalid ones that take their time before giving up.

As you say, it's not an AutoIt issue, but a Windows one. I'm trying to find a creative way around the problem. The method I mentioned wouldn't be any quicker, it's just it would be another script running in the background gathering all the required information that the user wasn't aware of. The main script could then reference that information to get a quicker response than asking Windows direct. What do you think?

Share this post


Link to post
Share on other sites

Sorry I don't have good AD experience to help you on this.

I thought that a correctly setup domain would tag invalid UNCs right away, and all large corp MS networks I've seen used to work (or rather fail) decently fast in such case, but this is outdated experience. All trolling about MS apart, I suspect there should be settings in your DC to rule out bad UNCs quickly but it may need to determine what is causing the delay: bad server, bad path, bad rights.

BTW, good UNCs & rights are sometimes causing the same irritating delay issue on a MS peer LAN. Hence my mention of Master Browsers. But this is probably unrelated to your situation.

I hope someone more knowledgeable will take over the issue and offer a smart and solid solution.

I whish you best of luck.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Similar Content

    • harrigme
      By harrigme
      This is probably very basic but I am trying to run Koda FormDesigner and if I click on "Generate Form Code" or "Generate Options" it freezes the program.  Any ideas on how to fix this?
    • ruslanas402
      By ruslanas402
      Greeting, so I've been trying to come up with solution, but no luck. Despite I tried to automate upload function, I released that it freezes after "Choose File to Upload" window appears..
       
      #include <IE.au3> ;#include <_Dbug.au3> Global $oIE = _IECreate("http://tinypic.com/", 1) Global $upload2 = _IEGetObjById($oIE, "the_file") _IEAction($upload2, "click") ;Sleep(1000) $hWnd = WinGetHandle("Choose File to Upload") MsgBox(0, "", $hWnd) Have anybody faced this situation?
      btw: srry for the advertise Besides it's no matter which site I'm trying to do this it's all the same.
    • cookiemonster
      By cookiemonster
      Hi,
      I have a form which calls this function:
      Func HostToIP($Host, $Label) TCPStartup() Local $sIPAddress = TCPNameToIP($Host) If @error Then GUICtrlSetData ($Label, "Error code: " & @error) Else GUICtrlSetData ($Label, $sIPAddress) EndIf TCPShutdown() EndFunc But if it cannot resolve the host to an IP, the whole form freezes for a few seconds until the TCPNameToIP times out, how can I stop the form from freezing whilst it waits for the host to ip times out?
      TCPNameToIP is part of #include <_sql.au3>
    • Gibbo
      By Gibbo
      Hi All, 
      I went searching for something to speed up checking for files on the network (UNC Paths)
      Most examples were rather complicated but someones multi-threaded solution gave me an idea.
      Hope it is useful to someone.
      Seems to work well so far. 
       
      Func _FileExistsTimeout($sPath, $iTimeout = 1000) Local $hTimer = TimerInit() ; Begin the timer and store the handle in a variable. Local $iPID = Run(@AutoItExe & ' /AutoIt3ExecuteLine "ConsoleWriteError(FileExists(""' & $sPath & '""))"', @ScriptDir, @SW_HIDE, $STDERR_CHILD) Local $sOutput = "" Local $iDiff = 0 While $iDiff < $iTimeout $iDiff = TimerDiff($hTimer) $sOutput &= StderrRead($iPID) If @error Then ; Exit the loop if the process closes or StderrRead returns an error. ExitLoop EndIf WEnd ProcessClose($iPID) Switch StringStripWS($sOutput, 8) Case 1 Return True Case Else Return False EndSwitch EndFunc ;==>_FileExistsTimeout
    • JonBMN
      By JonBMN
      Just trying to use a simple While loop to watch for input in a GUI window, but when I go to run it and then give the input. It seems to completely hang and I must at that point stop it manually and restart. I know I'm missing something (could be trivial), but a push would be greatly appreciated.

      #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiButton.au3> #include <EditConstants.au3> #include <MsgBoxConstants.au3> Local $F1Button, $F1Key HotKeySet("{Esc}", "Quit") $F1Key = HotKeySet("{F1}", "UnlockCar") GUI() While 1     $msg = GUIGetMsg()     Select         Case $msg = $GUI_Event_Close             Quit()         Case $msg = $F1Button             UnlockMe()     EndSelect WEnd Func GUI()     $DisclaimerHandle = GUICreate("Disclaimer", 525, 245, -1, -1, -1, $WS_EX_TOPMOST) ;Creates the GUI window     GUICtrlCreateLabel("example", 7, 15)     GUICtrlCreateLabel("", 7, 30)     GUICtrlCreateLabel("example", 7, 45)     GUICtrlCreateLabel(" example", 7, 60)     GUICtrlCreateLabel("", 7, 75)     GUICtrlCreateLabel("example", 7, 90)     GUICtrlCreateLabel("example", 7, 105)     GUICtrlCreateLabel("example", 7, 135)     GUICtrlCreateLabel("example", 7, 165)     GUICtrlCreateLabel("if using a touchscreen press the F1 button below.", 7, 180)     $F1Button = GUICtrlCreateButton("F1", 217, 205, 50, 30)     GUISetState(@SW_SHOW) ;Shows the GUI window EndFunc   ;==>GUI Func UnlockMe()     MsgBox(0, "I work", "I work")     Quit() EndFunc   ;==>UnlockMe Func Quit()     GUIDelete()     Exit EndFunc   ;==>Quit