How to Run Typeperf from Batch File?

How to Run Typeperf from Batch File?

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

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

James H. Sterling
Author

James H. Sterling

James Sterling reports on renewable energy developments, climate policy, ecological conservation, and green tech innovations around the globe.