First use this script (save it like toCSV.bat
for example).It will save an excel file as csv (though the arguments needs to be full paths):
@if (@X)==(@Y) @end /* JScript comment
@echo off
cscript //E:JScript //nologo "%~f0" %*
exit /b %errorlevel%
@if (@X)==(@Y) @end JScript comment */
var ARGS = WScript.Arguments;
var xlCSV = 6;
var objExcel = WScript.CreateObject("Excel.Application");
var objWorkbook = objExcel.Workbooks.Open(ARGS.Item(0));
objExcel.DisplayAlerts = false;
objExcel.Visible = false;
var objWorksheet = objWorkbook.Worksheets(ARGS.Item(1))
objWorksheet.SaveAs( ARGS.Item(2), xlCSV);
objExcel.Quit();
Then check this. And here's the final script (you can alter the result and redirect it to a file).Probably you'll have to change the name of the excel book and the sheet:
@echo off
setlocal enableDelayedExpansion
call toCsv.bat "%cd%\Book1.xlsx" Sheet1 "%cd%\csvIP.csv"
for /f "usebackq skip=1 tokens=3,4 delims=," %%a in ("csvIP.csv") do (
for /f %%# in ('powershell "$t = New-Object Net.Sockets.TcpClient;try{$t.Connect("""%%~a""", %%~b)}catch{};$t.Connected"') do set "open=%%#"
echo %%a %%b !open!
)