Some time we need to debug a program which run using cmd.exe under system account(NT AUTHORITY\SYSTEM).
We can use psexec program from sysinternals’ PsTools to achieve this.

To use it, put pstools folder on your system path and execute
psexec -i -s cmd.exe
where arguments -i if for interactive and -s is for system account