vb6 on xp GetAttr("hiberfil.sys") gives RunTimeErr=5

On XP using VB6 in a DIR$ loop for all attribs when GetAttr() encounters "hiberfil.sys" I get a run time err = 5. What the ...
Who is Participating?
zzzzzoocConnect With a Mentor Commented:
There are some system files you seem to not be able to access. Use an If/Else statement or what-not to avoid it. The same applies to "pagefile.sys" (error I came across not too long ago).
These files (hiberfil and pagefile) are virtual files - they doesn't exists on HDD, but are creating during system boot - this is why they can not be read
The file actually exists and if you change the system's pagefile to point to another, you can delete the old. And if it's just an  empty file and the MFT reserves the disk-space for it for the system to use, the "virtual memory" data will still exist on the HDD.
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Private Sub Command1_Click()
   Dim fso As Object
   Dim f As Object
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set f = fso.GetFile("c:\hiberfil.sys")
   MsgBox GetFileAttr(f.Attributes), vbInformation, "hiberfil.sys attributes:"
   Set f = Nothing
   Set fso = Nothing
End Sub

Private Function GetFileAttr(ByVal lAttr As Long) As String
   Dim sAttr As String
   If lAttr And vbDirectory Then sAttr = "Directory"
   If sAttr <> "" Then sAttr = sAttr & vbCrLf
   If lAttr And vbSystem Then sAttr = sAttr & "System"
   If sAttr <> "" Then sAttr = sAttr & vbCrLf
   If lAttr And vbHidden Then sAttr = sAttr & "Hidden"
   If sAttr <> "" Then sAttr = sAttr & vbCrLf
   If lAttr And vbArchive Then sAttr = sAttr & "Archive"
   GetFileAttr = sAttr
End Function
Is that supposed to mean the file doesn't exist? Then if it doesn't exist.. you can't delete it, right?.. ;)

"How to Delete the Pagefile.sys File in Recovery Console"

"How to Manually Remove Windows XP and Restore Windows 95, Windows 98, or Windows Millennium"

You'll notice "..Delete the Pagefile.sys and the Hiberfil.sys files." within the second and the first one is obvious. Nothing like deleting files that don't exist.. ;) Of course Microsoft doesn't know what they're talking about.. :[
Sorry, my fault based on folowing MS words:
>>Windows NT uses a paging file for virtual memory called PAGEFILE.SYS.<< Agreed these files exists but are heavely protected by OS.
shifty12Author Commented:
Win-98 had paging files and other sys-files and vb6 never had a prob. I miss 98.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.