Solved

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

Posted on 2004-04-07
8
639 Views
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 ...
shifty@lighthouse.net
thanx
0
Comment
Question by:shifty12
  • 3
  • 3
8 Comments
 
LVL 17

Accepted Solution

by:
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).
0
 
LVL 27

Expert Comment

by:Ark
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
0
 
LVL 17

Expert Comment

by:zzzzzooc
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.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 27

Expert Comment

by:Ark
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
0
 
LVL 17

Expert Comment

by:zzzzzooc
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"
http://support.microsoft.com/?kbid=255205

"How to Manually Remove Windows XP and Restore Windows 95, Windows 98, or Windows Millennium"
http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3BQ314052

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.. :[
0
 
LVL 27

Expert Comment

by:Ark
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.
0
 

Author Comment

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

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

708 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now