There is a limitation in VBS that does not allow setting a pagefile over the 4GB mark. I am not sure of the reasoning behind this, but you are right that detecting a value over to 4096 and reducing down is the answer. If you require a pagefile of bigger than 4gb then you'll most likely need to manually set the settings in windows.