read each line to a new variable in batch

November 8, 2010 at 11:14:29
Specs: Windows XP
I have a WOL command, for example: "wolcmd 00e0b86e02e1 "

This will output:

Wake On Lan signal sent to Mac Address 00e0b86e02e1
via Broadcast Address on port 7

It's 2 lines....

I want to use EventCreate to write an eventlog entry, but I can not get both lines to write to a variable. If I use for loops or temporary files I always get just the last line....

Here is how I envisioned the eventcreate script looking, but I can't get the variables in correctly:

eventcreate /T INFORMATION /ID 22 /L APPLICATION /D "%var1% %var2% Woke machine BASEMENT" /SO ScottScript

Also would like a carriage return after the variables, but beggars can't be choosers...

See More: read each line to a new variable in batch

Report •

November 8, 2010 at 11:29:29
@echo off & setLocal EnableDELAYedeXpansion

for /f "tokens=* delims= " %%a in (wake) do (
set V=!V!%%a

Life is too important to be taken seriously.


Report •

November 8, 2010 at 12:49:52
Awesome, thanks! I have no idea why that works, but it's great... Any way to put a carriage return in to my eventcreate statement between the variables?

Report •

Related Solutions

Ask Question