Jump to content



Photo

FileExists Not Working With Hiberfil.sys


  • Please log in to reply
11 replies to this topic

#1 Christian Blackburn

Christian Blackburn

    Wayfarer

  • Active Members
  • Pip
  • 93 posts

Posted 15 July 2006 - 07:00 AM

Hi Gang,

I came across an interesting bug on my Windows XP Pro computer for which I am the administrator. The following script doesn't show my hibernation file which is in fact there. It must be because the file is hidden, system, or a protected operating system file. As a diagnostic measure I checked my explorer view settings and I even have it enabled to show protected operating system files. However, an application should be able to detect that file even if explorer won't show it.

$Hibernate_Path = StringLeft(@WindowsDir, 2) & "\hiberfil.sys"                 MsgBox(4096, "$Hibernate_Path", $Hibernate_Path)                 ;Debug this isn't bloody working! If FileExists($Hibernate_Path) = 1 Then                         MsgBox(4096, "Debug", "The hibernation file exists!") Else     MsgBox(4096, "Debug", "The hibernation file doesn't exist!") EndIf


This bug exists both in the current stable and beta versions (3.1.1.30 at the time of writing).

Thanks,
Christian Blackburn





#2 MHz

MHz

    Just simple

  • MVPs
  • 5,400 posts

Posted 15 July 2006 - 08:50 AM

I have done some comparing with debugging with VBScript and AutoIt under same conditions.

Same files checked with both scripts
VBScript can find all files.
AutoIt3 cannot find pagefile.sys and hiberfil.sys.

VBScript test:
Set oFSO = CreateObject("Scripting.FileSystemObject") Set oShell = WScript.CreateObject ("WScript.Shell") WScript.Echo "Current Directory: " & oShell.CurrentDirectory oShell.CurrentDirectory="C:\" WScript.Echo "New Current Directory: " & oShell.CurrentDirectory filecheck = Array("autoexec.bat", "boot.ini", "config.sys", "hiberfil.sys", "io.sys", "msdos.sys", "ntdetect.com", "ntldr", "pagefile.sys") For i = 0 To UBound(filecheck)     If oFSO.FileExists(filecheck(i)) Then         MsgBox "found " & filecheck(i), 0     Else         MsgBox "Not found " & filecheck(i), 16     End If Next Set oFSO    = Nothing Set oShell  = Nothing WScript.Quit


AutoIt3 test:
$file = StringSplit('autoexec.bat|boot.ini|config.sys|hiberfil.sys|io.sys|msdos.sys|ntdetect.com|ntldr|pagefile.sys', '|') MsgBox(0, @AutoItVersion, 'WorkingDir: ' & @WorkingDir) If FileChangeDir(@HomeDrive & '\') Then     MsgBox(0, @AutoItVersion, 'New WorkingDir: ' & @WorkingDir)     If Not @error Then                                      For $i = 1 To $file[0]             If FileExists($file[$i]) Then                 MsgBox(0, @AutoItVersion, $file[$i] & " exists!")             Else                 MsgBox(0x10, @AutoItVersion, $file[$i] & " doesn't exist!")             EndIf         Next     EndIf EndIf


#3 Christian Blackburn

Christian Blackburn

    Wayfarer

  • Active Members
  • Pip
  • 93 posts

Posted 15 July 2006 - 08:55 AM

Hi MHZ,

Way to go. I also thought about using the FSO to see what it would return, also the findFirstFile function, but I knew this was a bug and that the sooner I posted it the sooner it would fixed. I appreciate your additional research and enginuity.
Thanks,Christian BlackburnHTTP://www.RawSeattle.org

#4 Jon

Jon

    Up all night to get lucky

  • Administrators
  • 9,529 posts

Posted 15 July 2006 - 08:58 AM

Hmm, I remember this bug from way back and am certain we fixed it. Strange.

#5 Christian Blackburn

Christian Blackburn

    Wayfarer

  • Active Members
  • Pip
  • 93 posts

Posted 15 July 2006 - 09:06 AM

Hi MHZ,

I would like to confirm your findings using the FSO object. The hibernation file was indeed detectable using the FSO.

Dim $FSO $FSO = ObjCreate("Scripting.FileSystemObject") If $FSO.FileExists("C:\hiberfil.sys")  Then     MsgBox(4096, "Status", "Hibernation File Found!") else     MsgBox(4096, "Status", "Hibernation File Not Found!") EndIf If $FSO.FileExists("C:\boot.ini") Then     MsgBox(4096, "Status", "boot.ini File Found!") else     MsgBox(4096, "Status", "boot.ini File Not Found!") EndIf If $FSO.FileExists("C:\nonsense.test") Then     MsgBox(4096, "Status", "Non-existant File Found!") else     MsgBox(4096, "Status", "Non-existant File Not Found!") EndIf


That of course needs to be run on a Win2K or higher system installed on the C:\ partition. PS what happened to the [ auotoit ] command? That used to work great.

Edited by Christian Blackburn, 15 July 2006 - 09:07 AM.

Thanks,Christian BlackburnHTTP://www.RawSeattle.org

#6 Jon

Jon

    Up all night to get lucky

  • Administrators
  • 9,529 posts

Posted 15 July 2006 - 09:09 AM

That of course needs to be run on a Win2K or higher system installed on the C:\ partition. PS what happened to the [ auotoit ] command? That used to work great.

I broke it last night. Should be working again now though.

#7 Christian Blackburn

Christian Blackburn

    Wayfarer

  • Active Members
  • Pip
  • 93 posts

Posted 15 July 2006 - 09:10 AM

Hmm, I remember this bug from way back and am certain we fixed it. Strange.


Hi Jon,

That sucks, perhaps someone merged the old over the new using a comparison tool by accident. Well at least you'll know how to fix it :D .

Edited by Christian Blackburn, 15 July 2006 - 09:11 AM.

Thanks,Christian BlackburnHTTP://www.RawSeattle.org

#8 Christian Blackburn

Christian Blackburn

    Wayfarer

  • Active Members
  • Pip
  • 93 posts

Posted 15 July 2006 - 09:15 AM

Thanks Jon. I look forward to it working again in 3.1.1.131.
Thanks,Christian BlackburnHTTP://www.RawSeattle.org

#9 SmOke_N

SmOke_N

    It's not what you know ... It's what you can prove!

  • Moderators
  • 15,729 posts

Posted 15 July 2006 - 10:11 AM

Thanks Jon. I look forward to it working again in 3.1.1.131.

I'm fairly sure he was talking about the AutoIt Code Tags for the forum on that one CB.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.


#10 Christian Blackburn

Christian Blackburn

    Wayfarer

  • Active Members
  • Pip
  • 93 posts

Posted 15 July 2006 - 10:49 AM

Hi SmOke_N,

I'm fairly sure he was talking about the AutoIt Code Tags for the forum on that one CB.


Thanks! I was wondering why he said he just broke it when .130 must have been out for a few days now. Hopefully he can just compare with an older copy in his versioning system and figure out what went wrong.
Thanks,Christian BlackburnHTTP://www.RawSeattle.org

#11 Jon

Jon

    Up all night to get lucky

  • Administrators
  • 9,529 posts

Posted 15 July 2006 - 02:02 PM

Fixed in 3.1.1.131.

#12 Richard Robertson

Richard Robertson

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 9,692 posts

Posted 15 July 2006 - 02:55 PM

[sarcasm]No, I think he meant the AutoIt tag for injecting code into a source file.[/sarcasm]




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users