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

Posted on 2004-04-07
Last Modified: 2008-02-01
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 ...
Question by:shifty12
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
LVL 17

Accepted Solution

zzzzzooc earned 50 total points
ID: 10777978
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).
LVL 28

Expert Comment

ID: 10780236
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
LVL 17

Expert Comment

ID: 10780303
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.
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

LVL 28

Expert Comment

ID: 10780334
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
LVL 17

Expert Comment

ID: 10780421
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.. :[
LVL 28

Expert Comment

ID: 10781415
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.

Author Comment

ID: 10791956
Win-98 had paging files and other sys-files and vb6 never had a prob. I miss 98.

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question