Skip to content
View in the app

A better way to browse. Learn more.

MSFN

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Need to retrieve the cpu utilization in Windows PE 2.1 version

Featured Replies

I am working to get the CPU Usage for WinPE 2.1 . First i tried it through wmi using the below method

set oSvc = GetObject("winmgmts:root\cimv2")

wqlQuery = "select LoadPercentage from Win32_Processor where DeviceID = 'CPU0'"

for each oData in oSvc.ExecQuery(wqlQuery)

for each oProperty in oData.Properties_

if oProperty.Name = "LoadPercentage" then

proc0Load = oProperty.Value

end if

next

next

wscript.echo Time() & "," & proc0Load & ","

It is working for all OS except WinPE and Vista as i have seen in wbemtest the Load Percentage value is coming there as NULL.

After that i tried to get the CPU usage using Performance Counters.

The CPU usage counter is of type PERF_100NSEC_TIMER_INV which has the following calculation:

100*(1-(X1-X0)/(Y1-Y0))

X - CounterData

Y - 100NsTime

Time base - 100Ns

where the denominator (Y) represents the total elapsed time of the sample interval and the numerator (X) represents the time during the interval when the monitored components were inactive.

CCpuUsage class has a method called GetCpuUsage which runs through the performance objects and counters and retrieves the CPU usage. Since the CPU usage can be determined by two samplings, the first call to GetCpuUsage() returns 0, and all calls thereafter returns the CPU usage.

But here also i am not getting the correct CPU Usage. It is showing as 0 and then jumping to 100 directly for WinPE2.1

May be the Performance counters are not supported in Vista and WinPE.

Please guide me if i am correct in my approach till now.

If not, please provide me the way to get the CPU Usage in WINPE 2.1 version.

Waiting for the quick reply.

Thanks in advance.

  • 2 weeks later...

  • Author

Please provide your response if any body have some knowledge about the topic. Its urget.

Sorry, it works for me.

On Error Resume Next

Const wbemFlagReturnImmediately = &h10

Const wbemFlagForwardOnly = &h20

arrComputers = Array(".")

For Each strComputer In arrComputers

WScript.Echo

WScript.Echo "=========================================="

WScript.Echo "Computer: " & strComputer

WScript.Echo "=========================================="

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")

Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Processor", "WQL", _

wbemFlagReturnImmediately + wbemFlagForwardOnly)

For Each objItem In colItems

WScript.Echo "LoadPercentage: " & objItem.LoadPercentage

WScript.Echo

Next

Next

Function WMIDateStringToDate(dtmDate)

WScript.Echo dtm:

WMIDateStringToDate = CDate(Mid(dtmDate, 5, 2) & "/" & _

Mid(dtmDate, 7, 2) & "/" & Left(dtmDate, 4) _

& " " & Mid (dtmDate, 9, 2) & ":" & Mid(dtmDate, 11, 2) & ":" & Mid(dtmDate,13, 2))

End Function

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.