“Ping” Command doesn’t work

Quite often that some of the command doesn’t work in the command prompt, showing some errors like

‘ping’ is not recognized as an internal or external command
‘defrag’ is not recognized as an internal or external command
‘ipconfig’ is not recognized as an internal or external command

but every time I forget about the fix, so let me put it here this time.

For Windows XP:

Right click “My Computer” and click “Properties”. Click the “Advanced” tab up top followed by the “Environment Variables” button at the bottom. In the 2nd list box, scroll down to the 5th or 6th entry “Path”, select it and click “Edit”. Add “%SystemRoot%system32;%SystemRoot%;” (minus the quotes) to the beginning of the line. Okay the changes and try out your commands now.