[Lazarus] Capturing the output from a command using TPorcess

Frederic Da Vitoria davitofrg at gmail.com
Mon Jul 20 23:23:06 CEST 2015


2015-07-20 21:41 GMT+02:00 Richard Mace <richard.mace at gmail.com>:

>
> Hi All,
> I hope this question is going to make sense.
> I am trying to obtain the MAC Address of a remote PC, using psexec
> \\pcname and running the command "ipconfig /all".
> If I run the psexec command from my machine via a command prompt, ipconfig
> /all is successfully run on the remote machine, and I can see it's MAC
> address, however, if I run it via TProcess, in Lazarus, the output I get
> from TProcess is the output from psexec (successfully run and exited with
> error code 0) rather than the output from ipconfig.
> How can I code TProcess, so that it shows me the output from the "ipconfig
> /all" command instead?
>

Hello,

This is not exactly what you asked for, but you could simply redirect the
output with something like "ipconfig /all > ipconfig..txt" then read the
contents of ipconfig.txt (or whatever name you gave to the output file).
You must take care where you put the output file, though: you must have the
rights to write in that folder.

Of course my solution is only a quick trick, the answer to your question
would be much cleaner and much more interesting.

-- 
Frederic Da Vitoria
(davitof)

Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20150720/14509216/attachment-0003.html>


More information about the Lazarus mailing list