I can't run the command using batch file to execute typeperf command

CDWANG

New Member
Hi ,

Can anyone advise on this.

I was running a command as below using cmd batch file

typeperf "\Processor(_Total)\% Processor Time" >> Memory.txt

However, I could not display the output to the text file and it shows error :

Error: No valid counters.

"
In order to use typeperf, you must either be a member of the local
Performance Log Users group, or the command must be executed from an
elevated command window."



Please help to advice what can be done.


Regards
CD
 

Attachments

  • Capture3.PNG
    Capture3.PNG
    23.5 KB · Views: 3
Try typeperf "\Processor(_Total)\% Processor Time" -f csv -o Memory.txt

Edit. Whoops. Read the message wrong. Try running the command prompt as administrator. But the -o thing should work too.
 
Hi Cromewell, tks for your advice.

May I know if I want to see only 10 processor percentage, what should I do to include on this command ?

Please advice.

Regards
CD
 
Hi, I try the command using a notepad and save as batch file.
Once I save in batch file, I run as administrator but I found that it still shows an error as attached.


Regards
CD
 

Attachments

  • Capture4.PNG
    Capture4.PNG
    29.1 KB · Views: 3
May I know if I want to see only 10 processor percentage, what should I do to include on this command ?
Sorry I don't fully understand your question. Do you want to see processor usage in blocks of 10%, the usage from 10 processors? The usage of the top 10 processes? Something else? I don't know if any of those are possible, I need to read the perf counter docs. Might need some wacky powershell for it.

Hi, I try the command using a notepad and save as batch file.
Once I save in batch file, I run as administrator but I found that it still shows an error as attached.
Rather than: typeperf "\Processor(_Total)\% Processor Time" >> Memory.txt
Try the command as: typeperf "\Processor(_Total)\% Processor Time" -o Memory.txt

Seems you can't redirect output from typeperf with the >/>> operators.
 
If you can, use powershell.

Just run

Code:
$file = "~/Documents/CpuUsg.txt";
for($i = 1; $i <= 10; $i += 1) {
  $(gwmi win32_processor).LoadPercentage >> $file;
  "`r`n" >> $file # adds a new line
}

Notepad.exe $file;

That should do what you want hopefully.

With powershell, you can access the dotnet framework. You can use the performance counters in C#/F#/VB if you like. Needs a bit more code to use though.
 
Back
Top