Try searching the IO forum for "StreamGobbler", which addresses the tricky bits of reading the output from the command. Some commands require you to read the output even if you don't need it for your logic. Some of the examples in the old gobbler threads are pretty complete solutions.
If you're in Windows, open a command prompt and run "CMD /?" and "COMMAND /?". You'll need to know one or both of these to run so-called internal commands and a few other finicky programs.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi