The VSPerfCmd.exe Attach option begins sample profiling of the running process specified by the process ID (PID).

To use the Attach option, you must specify the Sample method in the Start option.

Note Note

If the Start option was specified with the Crosssession option, any calls to VSPerfCmd /Attach or to VSPerfCmd /Detach must also specify Crosssession.

VSPerfCmd.exe /Attach:ProcessID [Options]


The process ID (PID) of the running process. The PID of a running process is listed on the Processes tab of Windows Task Manager.

The following VSPerfCmd options can be combined with the Attach option on a single command line.


Enables profiling applications in sessions other than the logon session. Required if the Start option was specified with the Crosssession option.

Start: Method

Initializes the command-line profiler session and sets the specified profiling method.


Specifies the version of the .NET Framework Common Language Runtime (CLR) to profile when more than one version is loaded in a profiling session. By default, the first loaded version is profiled.

GlobalOn GlobalOff

Resumes (GlobalOn) or pauses (GlobalOff) profiling, but does not end the profiling session.

ProcessOn: PID ProcessOff: PID

Resumes (ProcessOn) or pauses (ProcessOff) profiling for the specified process.

One of the following sampling interval options can be specified on the Attach command line. The default sampling interval is 10,000,000 processor clock cycles.


Specifies the number and type of the sampling interval.

  • Timer - Samples every Cycles processor clock cycles. If Cycles is not specified, 10,000,000 cycles are used.

  • PF - Samples every Events page faults. If Events is not specified, 10 page faults are used.

  • Sys - Samples every Events calls to the operating system. If Events is not specified, 10 system calls are used.

  • Counter - Samples every Reload number of the CPU performance counter specified by Name. Optionally, FriendlyName can specify a string to use as the column header in profiler reports.

This example demonstrates how to attach to a running instance of an application with the process ID of 12345.

VSPerfCmd.exe /Start:Sample /Output:TestApp.exe.vsp
VSPerfCmd.exe /Attach:12345