Board logo

标题: [问题求助] [已解决]VBS获取磁盘剩余百分比如何精确到小数点后两位? [打印本页]

作者: ydfan8888    时间: 2012-3-29 11:46     标题: [已解决]VBS获取磁盘剩余百分比如何精确到小数点后两位?

  1. Set objWMIService = GetObject("winmgmts:")
  2. Set objLogicalDisk = objWMIService.get("Win32_LogicalDisk.DeviceID='e:'")
  3. s = objLogicaldisk.Size/(1024*1024*1024)
  4. s = round(s,2) '全部磁盘容量
  5. m = objLogicalDisk.FreeSpace/(1024*1024*1024)
  6. m = round(m,2) '剩余磁盘空间
  7. a = m/s
  8. a = round(a,2)
  9. w = (FormatPercent(a,2)) '磁盘剩余空间百分比
复制代码

作者: batman    时间: 2012-3-29 12:39

  1. Set objWMIService = GetObject("winmgmts:")
  2. Set objLogicalDisk = objWMIService.get("Win32_LogicalDisk.DeviceID='e:'")
  3. s = objLogicaldisk.Size/(1024*1024*1024)
  4. s = round(s,2) '全部磁盘容量
  5. m = objLogicalDisk.FreeSpace/(1024*1024*1024)
  6. m = round(m,2) '剩余磁盘空间
  7. a = m/s
  8. a = round(a,4)
  9. w = (FormatPercent(a,2)) '磁盘剩余空间百分比
  10. MsgBox w
复制代码

作者: ydfan8888    时间: 2012-3-29 13:11

batman 发表于 2012-3-29 12:39



    谢谢 已经处理




欢迎光临 批处理之家 (http://bathome.net./) Powered by Discuz! 7.2