не надо никакого вывода в файл
X++:
COM wsh;
str _cmdStr;
str fullCommand, clearBuffCmd;
DLL winApiDLL = new DLL('user32');
DLLFunction openClipboard = new DLLFunction(winApiDLL, 'OpenClipboard');
DLLFunction getClipboardData = new DLLFunction(winApiDLL, 'GetClipboardData');
DLLFunction enumClipboardFormats = new DLLFunction(winApiDLL, 'EnumClipboardFormats');
DLLFunction closeClipboard = new DLLFunction(winApiDLL, 'CloseClipboard');
int format;
str resultStr;
;
openClipboard.returns(ExtTypes::DWord);
openClipboard.arg(ExtTypes::DWord);
enumClipboardFormats.arg(ExtTypes::DWord);
enumClipboardFormats.returns(ExtTypes::DWord);
getClipboardData.arg(ExtTypes::DWord);
getClipboardData.returns(ExtTypes::String);
closeClipboard.returns(ExtTypes::DWord);
closeClipboard.arg();
clearBuffCmd = 'cmd /c echo off | clip';
_cmdStr = "tracert 192.168.59.186";
fullCommand = 'cmd /c ' +'chcp 437 && '+ _cmdStr + ' | clip' ;
wsh = new COM('WScript.Shell');
wsh.Run(clearBuffCmd, 1, true);
wsh.Run(fullCommand, 1, true);
sleep(100);
wsh.finalize();
if(openClipboard.call(0))
{
format = enumClipboardFormats.call(0);
while(format)
{
switch(format)
{
case 1: //CF_TEXT
case 7: //CF_OEMTEXT
case 13: //CF_OEMTEXT CF_UNICODETEXT
resultStr = getClipboardData.call(format); // результат tracert или ping
break;
default:
break;
}
format = enumClipboardFormats.call(format);
}
closeClipboard.call();
}