I am using Windows Server 2008 and I want to get the DNS Server. So I tought that the fastest way should be executing ipconfig and then parsing it's output using TProcess.
I have came up with this code :
var
proces : TProcess;
begin
...
proces := TProcess.Create(nil);
proces.Executable := 'ipconfig';
proces.Options := proces.Options + [poWaitOnExit,poUsePipes];
try
proces.Execute;
except
proces.Free;
end;
SetLength(rez,proces.Output.NumBytesAvailable);
proces.Output.Read(rez[1],proces.Output.NumBytesAvailable);
ShowMessage(rez);
The code works but after I manually close the console window.I have tried poNoConsole
but still the same result, the process ipconfig remains active in taskmanager.
Why isn't the console application ipconfig terminating ? If I run it it exits after spitting stdout information.
Is it my configuration? Is it a bug ? Help! thanks :)