Recently Browsing 0 members
No registered users viewing this page.
I want to check if a file exists under the System32 folder: C:\Windows\System32\inetsrv\rewrite.dll
The following code always worked for me:
$string = @SystemDir & "\inetsrv\rewrite.dll" ConsoleWrite(FileExists($string)) But yesterday I updated my Windows 10 with the last "big" update and now my @SystemDir returns the following string:
And before it was:
So I thought I change my code to:
$string = @WindowsDir & "\System32\inetsrv\rewrite.dll" ConsoleWrite(FileExists($string)) But this code also does not work. I tried to run it as administrator but this also didn't work.
What am I doing wrong?
Have the following code snippet:
If not FileExists($ExchangeDir & $StockCSV) Then _FileWriteFromArray($ExchangeDir & $StockCSV, $YahooStockEntries) Else When trying to do a check against the non-existent file 'PRN.csv', FileExists is evaluating as True. This is not happening with other file names, directory structure is correct.
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
Prior to posting this question, I have experimented with using FileExists, InetGetInfo and InetGet/InetClose functions to test downloading files into my application folder, in case if my file did not already exist.
In my case, I was able to pinpoint to a very specific web address, eg.) https://dropbox.com, etc. and then check/download the file.
Now my question is, instead of checking from a hardcoded URL, is it possible to:
1. Do a check against the IP address of a remote computer, eg.) my friend's or colleague's desktop computer
2. After checking the IP address if valid and can be connected to, access the computer's hard drive location, eg.) that machine's C:specifiedFolderspecifiedFile.txt
3. Download a copy of that file into a local computer
I did read ('?do=embed' frameborder='0' data-embedContent>>) but that was what I accomplished earlier, so now I am not sure if I were to change the method of file retrieval, what changes are necessary?
FileExists returns a false negative if the path string is quoted. Windows sometimes uses these quotes to distinguish between path and argument parts of a path string. Thus a path variable pulled from the registry must have the quotes stripped or FileExists gives a false negative. The dos exist command, comspec and the FileOpenDialog, with the "File Must Exist" flag set, also allows these quotes.
Fixing this could also provide a method of extend the utility of FileExists and FileOpenDialog's "File Must Exist" flag without breaking any existing scripts. If FileExists optionally allowed these quotes, and only validated the string within the first pair of quotes if they exist, then script developers could easily validate a files existance even when it contains arguments quotes. Such as variables defined by path strings pulled from the registry, user supplied, etc.
Of course a script developer can easily provide this functionality themselves by providing a wrapper function for FileExists.