Velvet Star Monitor

Standout celebrity highlights with iconic style.

general

How to run typeperf from batch file?

Writer Andrew Henderson

How to run commands like

typeperf "\Process(*)\% Processor Time" -sc 1

from batch file?

Ran from command line this command outputs something monstrous, while ran from bat file it prints

Error: No valid counters.

2 Answers

You need to double the percent sign. From

Using a percent sign (%) in a batch file requires that two percent signs (%%) be specified.
(...)
MS-DOS uses %1, %2, ... %9 as replaceable command line parameters. For example, before executing the command ECHO %1, %1 will be replaced with the first parameter passed to the batch file. %0 is replaced with the command used to execute the batch file.

A single percent sign on a line is treated as a "nul" character in a batch file.

instead of using double % signs you could also use a config file for your counter settings like this:

tp.cfg:

\Processor(_Total)\% Processor Time
\Memory\Page Faults/sec

Then in your batch file call:

typeperf -cf "tp.cfg"

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy