OK, in the CMD type this in this order:
set PATH=%PATH%;c:\MinGW\bin
and then
mingw32-g++.exe -Wall -fexceptions -g -c main.cpp -o main.o
The first command will add the MinGW compiler directory to your path so cmd can find the compiler command. The second command will try to build your source without codeblocks, so we can see if something is blocking the compiler.
[Edit:] as soon as you close the cmd you will have to retype the first command.