Hi,
First of all, because "ipconfig" is a program in its own right, you don't need to open it with a command prompt. If you wanted to run it manually to check an IP, you would have to use the command prompt as you need a program to catch and display ipconfig's output, however as your program is supposed to catch the output instead, you don't need it.
Working example :-( Found not to work in most cases - scroll down to later posts for a working version!
Also, you may want to note that all processes you run are terminated when your blitz app ends, so no need to add this manually (notice the use on OnEnd at the bottom of freeprocess.bmx).
The thing to remember is that the pipe field of TProcess can basically be read from and written to exactly like any other stream, as it extends TStream.
Hope this helps,
Seb
First of all, because "ipconfig" is a program in its own right, you don't need to open it with a command prompt. If you wanted to run it manually to check an IP, you would have to use the command prompt as you need a program to catch and display ipconfig's output, however as your program is supposed to catch the output instead, you don't need it.
SuperStrict Framework brl.standardio Import pub.freeprocess ?Win32 'Lets use OO for the hell of it, although you can use CreateProcess() if you prefer 'There is only 1 flag available - HIDECONSOLE that is supposed to hide console output ;-) but it doesn't make much difference either way on my Windows machine Local temp_process:TProcess = TProcess.Create("ipconfig",HIDECONSOLE) Print "" Print "IPConfig Status: " + temp_process.Status() 'Show that the program is running Print "================================" While temp_process.Status() 'Checks to see if the process is still running 'Check if the pipe contains any data that hasn't been read and if so, output a line If temp_process.pipe.ReadAvail() Then Print ReadLine$(temp_process.pipe) Wend 'Terminate process manually (the fact that is has escaped the above loop means it has already closed but put it in as an example) temp_process.Close() 'This is a quick way you can terminate all processes without bothering to loop through them all (again not needed) TProcess.TerminateAll() Print "================================" Print "IPConfig Status: " + temp_process.Status() 'Show that the program has ended Print "" ?MacOs Print "Mac OS X doesn't have IpConfig." ?Linux Print "Linux doesn't have IpConfig." ?
Also, you may want to note that all processes you run are terminated when your blitz app ends, so no need to add this manually (notice the use on OnEnd at the bottom of freeprocess.bmx).
The thing to remember is that the pipe field of TProcess can basically be read from and written to exactly like any other stream, as it extends TStream.
Hope this helps,
Seb