
I execute
Net time \\{ip for any computer}
Return:
Current time at \\{ip for any computer} is {date and time}

and set Date and time a variable this no promblem
Moderator: DosItHelp
Code: Select all
for /f %%a in ('Net time \\{ip for any computer}') do set your_var=%%a
You can use a combination of "skip" and/or a goto statement to eliminate extra lines:jgamezu wrote:Yeah Men, I luv u!!!!!!!![]()
i got my data with:
example
-----------------
FOR /F "tokens=6*" %%A IN ('Net time \\{ip any computer}') DO set my_var=%%A %%B
Echo %my_var%
-----------------
today this resolved my problem![]()
but if the execute had a result with many lines you can see only the last line.
if the last line had a less tokens than penultimate you can see the last words or tokens of penultimate lines.
Code: Select all
for /f "tokens=6* skip=2" %%a in ('somecommand.cmd') do (
set something=%%a
)
Code: Select all
for /f "tokens=6*" %%a in ('someothercommand.cmd') do (
if %%a=="what we're looking for" (
set myvar=%%a
goto :continue
)
)
:continue
echo We broke out of the for loop
Code: Select all
@echo off
SET count=0
FOR /f "tokens=*" %%G IN ('{your command}') DO (call :do_sums "%%G")
Echo %line_str%
pause
GOTO :eof
:do_sums
set /a count+=1
Rem ****compare with number of line you want***
IF !%count%!==!1! SET line_str=%1
GOTO :eof