|
I'm writing a script to scan multiple computers (using WMI and looking into the registry) and get information like: installed programs, startup programs, locally logged user, etc.
I'm using the fping command to check if all the PC that I have in my list (or array) are connected to the lan. I'm using Fping because the ouput is a lot more readable than Ping (parameter to display only 1 line at the ouput). So I firstly wanted to ouput the result of the Fping to a text file then read the text file and check if it contains the string 'Reply'. If it does, then I stat querying all sort of stuff to the Host I fpinged. If it contains 'Host' or something else, it means the computer is off or does not exists, so I will skip this computer.
I wanted to optimize the speed of the fping (and avoid using temp files) by ouputing the result to a dos variable. To do this, I use: --> For /F %a in ('fping HOSTNAME -w20 -t1 -n1 -l') do SET fping_result=%a or from Kix: --> shell "%comspec% /C For /F %a in (" + CHR(39) + "fping " + $current_computer + " -w20 -n1 -l" + CHR(39) + ") do SET fping_result=%a"
This works fine, but it seems to create the variable in a Environement that disappears right after the command is completed, so I can't get the variable value back.
Launched from a dos prompt (without Kix), the variable is there.
Any suggestion?
Thanks.
Shinji.
|