Solved

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

Posted on 2004-04-07
8
647 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
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Suggested Solutions

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…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

803 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