Sign in to follow this  
Followers 0
Guest Kato

Can't Get Pagefile.sys File Info

5 posts in this topic

Whenever I use the FileExists, FileGetSize, or even the FileGetAttrib functions on the PageFile.sys in NT/W2K/XP ; I cannot get the information I want. I know that my pagefile.sys exists and is about 480MB, but these functions can't detect that the file exists nor give me the size. I tried to do this with a Kixtart script and had the same problem. It the OS preventing this info from being passed to the script? Is there a way around it?

I want to determine the size of the existing pagefile.sys, examine how much harddrive space is free, and readjust the page file with the Reg.EXE utility. Some machines have two partitions so the total pagefile reported by the MemGetStats function does not work for me because I don't know how much of the page file is stored on the C: drive and how much is on the D: drives.

Please help.

:D

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

you can dump the information:

$tempfile="c:\tempfile.tmp"
runwait(@comspec & " /c dir c:\pagefile.sys /as >"& $tempfile,"",@SW_MINIMIZE)
$x=Stringsplit(stringreplace(fileread($tempfile,Filegetsize($tempfile)),@lf,""),@cr)
for $i=5 to $x[0]
if stringinstr($x[$i],"pagefile.sys") then $info=$x[$i]
next
filedelete($tempfile)
msgbox(1,"",$info)

or if you want to see attributes, try this:

$tempfile="c:\tempfile.tmp"
runwait(@comspec & " /c dir c:\pagefile.sys /as >"& $tempfile,"",@SW_MINIMIZE)
$x=Stringsplit(stringreplace(fileread($tempfile,Filegetsize($tempfile)),@lf,""),@cr)
for $i=1 to $x[0]
if stringinstr($x[$i],"pagefile.sys") then $info=$x[$i]
next
filedelete($tempfile)
runwait(@comspec & " /c attrib c:\pagefile.sys >"& $tempfile,"",@SW_MINIMIZE)
$x=Stringsplit(stringreplace(fileread($tempfile,Filegetsize($tempfile)),@lf,""),@cr)
for $i=1 to $x[0]
if stringinstr($x[$i],"pagefile.sys") then $info2=$x[$i]
next
filedelete($tempfile)
msgbox(1,$info2,$info)

You can use this for most files, I left out error checks for file not found.

Edited by scriptkitty

AutoIt3, the MACGYVER Pocket Knife for computers.

Share this post


Link to post
Share on other sites

ScriptKitty,

That tip was absolutely awsome. It works like a charm. It will take me a few more minutes to fully understand the code, but I know in concept what it is doing. Thats great.

Thank you so much. I will save a copy of the code for future reference with a remark and credit to you:

; ======= Courtesy of ScriptKitty ===========

Func ?????????

; code

EndFunc

; Thanks again :D

Share this post


Link to post
Share on other sites

Larry,

Thank you for your input. Your tip will help in other areas of the script; however, for this particular issue, the actual pagefile file size can be anything between the minimum and maximum settings that are specified. That is why I needed to calculate the hard drive's free space + the size of the pagefile.sys file to come up with the actual amount that I can count on when re-adjusting the size.

Thanks :D

Share this post


Link to post
Share on other sites

PageFile.vbs, which is included in the Windows Resource Kit, allows you to get and change pagefile size with simple arguments passed to the script. It even allows you to work on remote machines so you could fix all of your PCs from one master console.

Jeff

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0