Jump to content

Moving the pagefile


Recommended Posts

After reading a good thread on manipulating the pagefile.. I have been experimenting, however I cannot seem to delete the active pagefile, even though I have created a new one...

I know this can be done manually, but it just seems to hang when it is processing the delet command, which I run after I have created a new pagefile on a different drive.... my batch file reads:

start /wait cscript //nologo //B //T:600 %systemroot%\system32\pagefileconfig.vbs /create /i 2560 /m 2560 /vo d:

start /wait cscript //nologo //B //T:600 %systemroot%\system32\pagefileconfig.vbs /delete /vo e:

I was trying to delete the pagefile on e (currently active), in favour of a new one on d, but am suspecting that this is the problem, although I know you can add and delte them manually....

Anyone got any ideas..??

Link to comment
Share on other sites


After testing various commands, I think Ive found the problem, but do not know how to get around it...

I have managed to execute the delete command, but a confirmation is prompted for to delete, however, if I try to supress script errors or prompts using the cscript.exe //B command, it wont execute at all..

I need to know how I can automatically enter Y to confirm execution of the script...

Anyone got any suggestions... its all getting a little deep for me now!!

I need an expert on scripting here I think..., there does not appear to be any commandline switches to auto accept/confirm the delete command, when run from a batch file, there needs to be some user input, if only hit y and enter... can someone please help!!

Thanks

Edited by drscouse
Link to comment
Share on other sites

Had a look in the pagefileconfig.vbs, and think Ive found the bit I need to ammend, which asks for confirmation of execution of the delete command:

Private Function isCrashDumpValueSet( ByVal intCrashDumpParam,_

                                      ByVal intIntSizeParam,  _

                                      ByVal intMemSizeParam,  _

                                      ByVal strVolume )

    ON ERROR RESUME NEXT

    Err.Clear

    ' Constants for Crash Dump Settings

    CONST NO_MEMORY_DUMP      = 0

    CONST COMPLETE_MEMORY_DUMP = 1

    CONST KERNEL_MEMORY_DUMP  = 2

    CONST SMALL_MEMORY_DUMP    = 3

    Dim strReply        ' to store user reply

    Dim intSizeValue    ' to store the size value used for comparison

    ' default value is NO [n]    strReply = L_UserReplyNo_Text

    Select Case CInt(intCrashDumpParam)

        Case COMPLETE_MEMORY_DUMP

            If CInt(intIntSizeParam) < CInt(intMemSizeParam) Then

                component.VBPrintf CrashDumpSettingWarningMessage, Array(UCase(strVolume),CInt(intMemSizeParam) & MEGA_BYTES)

                ' Ask for choice until a yes[y] or no[n] is given

                Do

                    strReply = getReply()

                    If Trim(LCase(strReply)) = L_UserReplyYes_Text Then

                        isCrashDumpValueSet = TRUE

                    ElseIf Trim(LCase(strReply)) = L_UserReplyNo_Text Then

                        isCrashDumpValueSet = FALSE

                    Else

                        WScript.Echo(L_InvalidUserReply_ErrorMessage)

                    End If

                Loop Until (Trim(LCase(strReply)) = L_UserReplyYes_Text OR Trim(LCase(strReply)) = L_UserReplyNo_Text)

            Else

                isCrashDumpValueSet = TRUE

            End If

        Case KERNEL_MEMORY_DUMP

            ' check if RAM size is less than or equal to 128 MB

            If CInt(intMemSizeParam) <= 128 Then

                ' assign size value to be checked to 50 MB

                intSizeValue = 50

            Else

                ' check if RAM size is less than or equal to 4 GB

                If CInt(intMemSizeParam) <= 4096 Then

                    ' assign size value to be checked to 200 MB

                    intSizeValue = 200

                Else

                    ' check if RAM size is less than or equal to 8 GB

                    If CInt(intMemSizeParam) <= 8192 Then

                        ' assign size value to be checked to 400 MB

                        intSizeValue = 400

                    Else

                        ' assign size value to be checked to 800 MB

                        intSizeValue = 800

                    End If

                End If

            End If

            If CInt(intIntSizeParam) < CInt(intSizeValue) Then

                component.VBPrintf CrashDumpSettingWarningMessage, Array(UCase(strVolume),intSizeValue & MEGA_BYTES)

                ' Ask for choice until a yes[y] or no[n] is given

                Do

                    strReply = getReply()

                    If Trim(LCase(strReply)) = L_UserReplyYes_Text Then

                        isCrashDumpValueSet = TRUE

                    ElseIf Trim(LCase(strReply)) = L_UserReplyNo_Text Then

                        isCrashDumpValueSet = FALSE

                    Else

                        WScript.Echo(L_InvalidUserReply_ErrorMessage)

                    End If

                Loop Until (Trim(LCase(strReply)) = L_UserReplyYes_Text OR Trim(LCase(strReply)) = L_UserReplyNo_Text)

            Else

                isCrashDumpValueSet = TRUE

            End If

        Case SMALL_MEMORY_DUMP

            ' initial size should not be less than 64 KB ( less than or equal to 0 MB )

            If CInt(intIntSizeParam) <= 0 Then

                component.VBPrintf CrashDumpSettingWarningMessage, Array(UCase(strVolume),"64 KB")

                ' Ask for choice until a yes[y] or no[n] is given

                Do

                    strReply = getReply()

                    If Trim(LCase(strReply)) = L_UserReplyYes_Text Then

                        isCrashDumpValueSet = TRUE

                    ElseIf Trim(LCase(strReply)) = L_UserReplyNo_Text Then

                        isCrashDumpValueSet = FALSE

                    Else

                        WScript.Echo(L_InvalidUserReply_ErrorMessage)

                    End If

                Loop Until (Trim(LCase(strReply)) = L_UserReplyYes_Text OR Trim(LCase(strReply)) = L_UserReplyNo_Text)

            Else

                isCrashDumpValueSet = TRUE

            End If

        Case NO_MEMORY_DUMP

            ' Crash Dump values 0 has no problem

            isCrashDumpValueSet = TRUE

    End Select

End Function

Gonna experiment when I get home...

Edited by drscouse
Link to comment
Share on other sites

If anyone is remotely interested, although it doesnt really look like it.. I have had success...

I can now create/delete the pagefile on which ever drive I chose, using an ameded script... which will run on my unattended disk...

Link to comment
Share on other sites

Hi

Just found yor thread. And yes there are other people out there with the same problem.

I'm quite new at this unattended stuff and are currently just experimenting. I would like to fix the size of the swapfile, maybe you can help me here.

Thanks in advance.

Link to comment
Share on other sites

No problem.. ive been messing about with the commands over the last few days, and can now move, change, resize, delete the pagefile via silent batch files, with no user intervention...

Deleting was a bit of a problem, as the script would ask for confirmation, during an unattended install, this is no good... but I was able to get around it by modifying the script itself, and tricking it into thinking that I had agreed to the confirmation request...

I have now been able to accomplish my task of re-assigning drive letters, and moving the pagefile during a Ua install...

Let me know what you are trying to do, and I will try to help....

Edited by drscouse
Link to comment
Share on other sites

What you need to do is either copy/edit the pagefileconfig.vbs (I made a copy for the pagefile delete process, just to be on the safe side...

Using pagefileconfig.vbs: http://www.microsoft.com/resources/documen...fileconfig.mspx

Near the end of the script, you will find:

Case SMALL_MEMORY_DUMP

            ' initial size should not be less than 64 KB ( less than or equal to 0 MB )

            If CInt(intIntSizeParam) <= 0 Then

                component.VBPrintf CrashDumpSettingWarningMessage, Array(UCase(strVolume),"64 KB")

                ' Ask for choice until a yes[y]or no[n] is given

                Do

                    strReply = getReply()

                    If Trim(LCase(strReply)) = L_UserReplyYes_Text Then

                        isCrashDumpValueSet = TRUE

                    ElseIf Trim(LCase(strReply)) = L_UserReplyNo_Text Then

                        isCrashDumpValueSet = FALSE

                    Else

                        WScript.Echo(L_InvalidUserReply_ErrorMessage)

                    End If

                Loop Until (Trim(LCase(strReply)) = L_UserReplyYes_Text OR Trim(LCase(strReply)) = L_UserReplyNo_Text)

            Else

                isCrashDumpValueSet = TRUE

            End If

        Case NO_MEMORY_DUMP

            ' Crash Dump values 0 has no problem

            isCrashDumpValueSet = TRUE

It is this part, we are interested in:

Do

                    strReply = getReply()

                    If Trim(LCase(strReply)) = L_UserReplyYes_Text Then

                        isCrashDumpValueSet = TRUE

                    ElseIf Trim(LCase(strReply)) = L_UserReplyNo_Text Then

                        isCrashDumpValueSet = FALSE

                    Else

I had messed about with the other procedures above this one, but found this one did the trick...

You need to amend it to the following:

Do

                    If Trim(LCase(strReply)) = L_UserReplyYes_Text Then

                        isCrashDumpValueSet = TRUE

                     ElseIf Trim(LCase(strReply)) = L_UserReplyNo_Text Then

                        isCrashDumpValueSet = TRUE

                    Else

Thereby removing the user input request, and accepting no input as a TRUE value, therefore confirming the procedure.

I saved the amended script file as custompagefile.vbs, and ran the following batch file:

cscript.exe //B c:/windows/system32/custompagefileconfig.vbs /delete /vo X:

Where //B is to supress prompting for user input (however, this alone will not force the an unamended script to run... it just hangs), and the amended script will return positive, and X is the location of the pagefile you wish to delete.

You will find that this will remove the pagefile from the Virtual Memory properties section, but you will still need to physically remove the pagefile.sys from the drive you have deleted it.

attrib -s -h pagefile.sys

del pagefile.sys

Hope this makes sense....

Edited by drscouse
Link to comment
Share on other sites

  • 2 years later...

I've been searching most of the day, through the forums, and this is the closest thread I've found relating to my desires. Unfortunately, after reading pages of posts, I'm more unsure of what to do, than when I started.

During an unattended install I am installing XP Pro on the C:\ drive (a 250 Gb HDD). I want to move or create/delete or whatever it takes to put the page file AND the Documents and Settings folder on D:/ drive (a 500 Gb HDD). He (my son) has 2 GB RAM and two nVidia 6800 GTX GPUs. His current setup is mine; a XP Pro, slip streamed with SP2, and Docs & Set moved to drive D:\, so that part I have done before.

Does the order of which is done first, page file or Docs & Set, matter at all? Should I try to figure out how to get the page file to the front of the disc; or, should I let windows put it where it wants? And, most importantly, how do I do what I want to do, primarily concerning the page file, puting it D:/, sizing it, deleating the old one, etc?

Link to comment
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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...