On Windows XP, programmatically set Pagefile to "No Paging File" on single c: drive

Posted by NBPC77 on Stack Overflow See other posts from Stack Overflow or by NBPC77
Published on 2010-05-11T14:58:21Z Indexed on 2010/05/11 15:24 UTC
Read the original article Hit count: 363

Filed under:
|
|
|

I'm trying to write a C#/.NET application that optimizes the hard drives for our XP workstations

  1. Set pagefile to "No paging file"
  2. Reboot
  3. Run a defrag utility to optimize the data and apps
  4. Create a contiguous page file
  5. Reboot, run pagedefrag from Sysinternals

I'm really struggling with #1. I delete the following key: SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management\PagingFiles

Upon reboot, the System Control Panel shows "No page file", but c:\pagefile.sys still exists and its in use by the SYSTEM process so I can't delete it and I can't optimize HD. I tried using PendingFileRenamingOperations and that bombs out too. I tried using WMI: Win32_PageFileSetting, but that only lets you set sizes (not zero--defaults to 2MB).

Of course, if I do the manual steps outlined above, it works.

I think I need an API call to make this happen.

© Stack Overflow or respective owner

Related posts about pagefile

Related posts about c#