I'm trying to set up an automated script for a Windows XP installer. It's a batch script that runs on first boot after installation, and among the things I'm trying to accomplish, is removing the pagefile from C: entirely, and putting a 16-768 MB pagefile on D: instead.
Here're my batch file instructions:
echo === Creating new page file on D: ...
cscript %windir%\system32\pagefileconfig.vbs /create /i 16 /m 768 /vo d: >nul
echo.
echo === Removing old page file from C: ...
cscript %windir%\system32\pagefileconfig.vbs /delete /vo C:
attrib -s -h c:\pagefile.sys
del c:\pagefile.sys
My problem is that while these are sane commands, the removal of the pagefile on C: requires me to reboot before those commands succeed.b Or, in other words — I have to first create the D: pagefile, then reboot and delete the c:\pagefile.sys file, or I'm stuck with a c:\pagefile.sys file which isn't even recognized by Windows itself (it'll just say that there's a page file on D:, and that C: has no pagefile at all). Obviously because already some pages are written to the C:\pagefile.sys file.
So how would I go about accomplishing this in one go? Or, in two gos, if this is "batch scriptable" :)
TIA,
Daniel :)
EDIT: I should probably clarify: Running those commands above are all valid, but they'll only succeed fully if I re-run the "attrib" and "del" commands at next boot. The C: pagefile is in use at the time, so I cannot delete the file it uses, and Windows itself won't remove it when I configure it to not use C: as a page file drive. Instead, it'll leave an orphaned c:\pagefile.sys file behind (which is really large).
I don't necessarily need this to work in one go, registering the last two commands to run after a reboot would also be great :)