How to run typeperf from batch file?

1

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.

Dims

Posted 2015-03-07T10:25:22.463

Reputation: 8 464

Answers

2

You need to double the percent sign. From http://support.microsoft.com/kb/75634

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.

wmz

Posted 2015-03-07T10:25:22.463

Reputation: 6 132

0

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"

Magier

Posted 2015-03-07T10:25:22.463

Reputation: 67