Board logo

标题: [问题求助] 请告诉把获取CPU温度的vb代码转成vbs代码 [打印本页]

作者: winload    时间: 2015-12-10 12:21     标题: 请告诉把获取CPU温度的vb代码转成vbs代码

  1. Private Sub Command1_Click()
  2.     MsgBox "CPU 温度 : " & CPU_Temperature & " C"
  3. End Sub
  4. Private Function CPU_Temperature() As Integer
  5.     Dim WMIsvc As Object
  6.     Dim CltItems As Object, CltItem As Object
  7.     Dim Q As String
  8.     Set WMIsvc = GetObject("winmgmts:\\.\root\WMI")
  9.     Q = "SELECT * FROM MSAcpi_ThermalZoneTemperature"
  10.     Set CltItems = WMIsvc.ExecQuery(Q, , 48)
  11.     For Each CltItem In CltItems
  12.         CPU_Temperature = CltItem.CurrentTemperature
  13.     Next
  14.     CPU_Temperature = (CPU_Temperature - 2732) / 10
  15.     Set CltItem = Nothing
  16.     Set CltItems = Nothing
  17.     Set WMIsvc = Nothing
  18. End Function
复制代码

作者: pcl_test    时间: 2015-12-10 14:15

  1. MsgBox "CPU 温度 : " & CPU_Temperature & "℃"
  2. Function CPU_Temperature()
  3. Set WMIsvc = GetObject("winmgmts:\\.\root\wmi")
  4. Set CltItems = WMIsvc.ExecQuery("Select * from MSAcpi_ThermalZoneTemperature",,48)
  5. For Each CltItem in CltItems
  6.     CPU_Temperature = CltItem.CurrentTemperature
  7. Next
  8. CPU_Temperature = (CPU_Temperature - 2732) / 10
  9. End Function
复制代码

作者: winload    时间: 2015-12-10 14:27

万分感谢!
作者: winload    时间: 2015-12-10 15:29

回复 2# pcl_test


    请问可以用批处理实现吗 可能吗? 在不调用vbs的情况下




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