I'm trying to run a script to move users page files from C: to D: (if they don't have enough space)
I've figured out how to do it by modifying HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management\PagingFiles
It works fine - a new page file is created on D:
But, the old page file isn't removed from C: on reboot (although it works fine if I make the change manually). After reboot I can actually delete it though, so it's no still in use - just hasn't been removed.
Is there a way to make that happen?
You shouldn't be hacking the registry to do this. You should be making the changes the correct way, by using the relevant win32 classes.
The classes you are looking for are Win32_PageFile and Win32_PageFileSetting.