CYCho Posted March 26, 2020 Share Posted March 26, 2020 (edited) I have a desktop and a notebook connected through a common router. In the notebook I have a code which checks if there is a file in the desktop. If FileExists("\\Desktop-Main\D\Data\list.txt") Then ; some code here Else ; some other code here EndIf This works fine when the notebook is connected to the desktop. When it is not, however, the code is hung for about 25 seconds until the FileExists function returns a 0 value. Even Ping("Desktop", 10) takes more than 2000 milliseconds. I would like to know if there is a quicker way to check the existence of a UNC path. Take a good care of your health. Edited March 26, 2020 by CYCho zPlayer - A Small Audio and Video Player Time Sync + SystemTimeAdjustment Link to comment Share on other sites More sharing options...
CYCho Posted March 26, 2020 Author Share Posted March 26, 2020 Below is the result of my tests: $t = TimerInit() $f1 = Ping("desktop-main", 10) ; $t1 = TimerDiff($t) $t = TimerInit() $f2 = FileExists("\\desktop-main\d\data") $t2 = TimerDiff($t) ConsoleWrite("Ping result: " & $f1 & ", " & $t1 & @CRLF & "FileExists result: " & $f2 & ", " & $t2 & @CRLF) 1. Console output when the notebook is connected >"C:\AutoIt\SciTE\..\AutoIt3.exe" "C:\AutoIt\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "C:\T-Clock_static\Temp.au3" /UserParams +>14:10:54 Starting AutoIt3Wrapper v.19.102.1901.0 SciTE v.4.1.2.0 Keyboard:00000412 OS:WIN_10/ CPU:X64 OS:X64 Environment(Language:0412) CodePage:949 utf8.auto.check:4 +> SciTEDir => C:\AutoIt\SciTE UserDir => C:\Users\CYCho\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper SCITE_USERHOME => C:\Users\CYCho\AppData\Local\AutoIt v3\SciTE >Running AU3Check (3.3.14.5) from:C:\AutoIt input:C:\T-Clock_static\Temp.au3 +>14:10:54 AU3Check ended.rc:0 >Running:(3.3.14.5):C:\AutoIt\autoit3.exe "C:\T-Clock_static\Temp.au3" +>Setting Hotkeys...--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop Ping result: 14, 34.6601 FileExists result: 1, 0.3269 +>14:10:54 AutoIt3.exe ended.rc:0 +>14:10:54 AutoIt3Wrapper Finished. >Exit code: 0 Time: 1.01 2. Console output when the notebook is disconnected >"C:\AutoIt\SciTE\..\AutoIt3.exe" "C:\AutoIt\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "C:\T-Clock_static\Temp.au3" /UserParams +>14:20:27 Starting AutoIt3Wrapper v.19.102.1901.0 SciTE v.4.1.2.0 Keyboard:00000412 OS:WIN_10/ CPU:X64 OS:X64 Environment(Language:0412) CodePage:949 utf8.auto.check:4 +> SciTEDir => C:\AutoIt\SciTE UserDir => C:\Users\CYCho\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper SCITE_USERHOME => C:\Users\CYCho\AppData\Local\AutoIt v3\SciTE >Running AU3Check (3.3.14.5) from:C:\AutoIt input:C:\T-Clock_static\Temp.au3 +>14:20:27 AU3Check ended.rc:0 >Running:(3.3.14.5):C:\AutoIt\autoit3.exe "C:\T-Clock_static\Temp.au3" +>Setting Hotkeys...--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop Ping result: 0, 2566.4348 FileExists result: 0, 23262.1627 +>14:20:53 AutoIt3.exe ended.rc:0 +>14:20:53 AutoIt3Wrapper Finished. >Exit code: 0 Time: 26.75 zPlayer - A Small Audio and Video Player Time Sync + SystemTimeAdjustment Link to comment Share on other sites More sharing options...
CYCho Posted March 26, 2020 Author Share Posted March 26, 2020 I found this. Quote This seems to be the best solution I found so far. Any other suggestion? zPlayer - A Small Audio and Video Player Time Sync + SystemTimeAdjustment Link to comment Share on other sites More sharing options...
seadoggie01 Posted March 26, 2020 Share Posted March 26, 2020 Can you ping the router first? This seems weird, but it can't hurt... Have you tried mapping the drive? Maybe trying/checking for the drive would go faster? All my code provided is Public Domain... but it may not work. Use it, change it, break it, whatever you want. Spoiler My Humble Contributions:Personal Function Documentation - A personal HelpFile for your functionsAcro.au3 UDF - Automating Acrobat ProToDo Finder - Find #ToDo: lines in your scriptsUI-SimpleWrappers UDF - Use UI Automation more Simply-erKeePass UDF - Automate KeePass, a password managerInputBoxes - Simple Input boxes for various variable types Link to comment Share on other sites More sharing options...
CYCho Posted March 26, 2020 Author Share Posted March 26, 2020 @seadoggie01 Thank you for your concern. FileExists for an invalid mapped drive took about the same time as for an invalid UNC path. seadoggie01 1 zPlayer - A Small Audio and Video Player Time Sync + SystemTimeAdjustment Link to comment Share on other sites More sharing options...
Nine Posted March 27, 2020 Share Posted March 27, 2020 @CYCho I was also interested by that issue, so I tested a few different ways : 1- shell.application object 2- DOS if exists 3- WinAPI_FileExists 4- File* functions All give more or less the same timeout delay. I believe the solution provided by Gibbo is the best there is... CYCho 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now