Fix compilation error in Windows.
Refactoring and allow more than one command to be repeated.