批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程
[批处理文件精品]批处理版照片整理器[批处理文件精品]纯批处理备份&还原驱动在线第三方下载
返回列表 发帖
我简化一下弄到D盘的:
  1. Function SetPageFile()'设置页面文件
  2.   Set colDrives = objFSO.Drives
  3.   drvnum=0
  4.   For Each objDrive in colDrives
  5.    if objDrive.DriveType=2 then drvnum=drvnum+1:if objDrive.DriveLetter="D" then t3=objDrive.FreeSpace
  6.   Next
  7.   if int(t3/1024/1024) < 4096 then SetPageFile="D盘空间太小":返回
  8.   Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate, (CreatePagefile, Shutdown)}!\\.\root\cimv2")
  9.   Set colPageFiles = objWMIService.ExecQuery("Select * from Win32_PageFileSetting")
  10.   For Each objPageFile in colPageFiles
  11.     objPageFile.Delete_()
  12.   Next
  13.   Set objPageFile = objWMIService.Get("Win32_PageFileSetting").SpawnInstance_()
  14.   objPageFile.Name = "d:\pagefile.sys"
  15.   if int(t3/1024/1024) < 8000 then
  16.       SetPageFile="D盘小于8G"
  17.       objPageFile.InitialSize = 1024 'MinSize
  18.       objPageFile.MaximumSize = 1024 'MaxSize
  19.       'SetPageFile="1024"
  20.   else
  21.       objPageFile.InitialSize = 2048 'MinSize
  22.       objPageFile.MaximumSize = 2048 'MaxSize
  23.       'SetPageFile="2048"
  24.   end if
  25.   objPageFile.Put_()
  26.   SetPageFile="ok"
  27. End Function
复制代码

TOP

返回列表