Re: Parsing file using FOR command not working correctly

From: foxidrive (foxidrive_at_Shotmail.com.invalid)
Date: 07/12/04


Date: Tue, 13 Jul 2004 03:32:27 +1000

On 12 Jul 2004 09:08:01 -0700, Dave Pink wrote:

> I'm using PsLogList from www.sysinternals.com to dump the contents of
> an Event Log. The output is saved to the file hotfix.txt.
>
> Contents of hotfix.txt:
>
> [3166] NtServicePack
> Type: INFORMATION
> Computer: PRDW2K-WEB109
> Time: 6/27/2004 2:02:37 AM ID: 4377
> Windows 2000 Hotfix KB837001 was installed.
>
>
> Using the FOR command, I'm trying to extract just the Event Log
> number; in this case it's 3166. I can't get it to work right.
>
>
> How can I set the variable "Number" equal to "3166"? Any help would be
> appreciated. Thanks.

@echo off
FOR /F "tokens=1 delims=[] " %%a in (hotfix.txt) DO SET Num=%%a&goto skip
:skip
ECHO %Num%



Relevant Pages

  • Re: Parsing file using FOR command not working asDave expects
    ... I'm trying to extract just the Event Log ... The for command iterates through all lines, ... In a regexp square brackets mark a range, ... echo %%a ...
    (microsoft.public.win2000.cmdprompt.admin)
  • Re: Service will not start after a reboot
    ... and the whole point of writing it as a service was to ... clues in the Event log and there are no dependencies on other services. ... Use the Task Scheduler to run the following batch file at boot ... echo %date% %time%>>c:\Waldy.log ...
    (microsoft.public.windowsxp.general)
  • Re: event logs
    ... I use task scheduler to run it and email it to me from the server. ... @echo off ... P.S. Dumpel does not export the DNS event log. ...
    (microsoft.public.win2000.security)
  • Windows event log event not being emailed
    ... event is seen in Nagios event log, ... nagios server service definition is below: ... @echo off ... echo Anhalten und Deinstallieren des Service "eventlog_agent" ...
    (RedHat)
  • Re: Parsing file using FOR command not working correctly
    ... @echo off ... I'm trying to extract just the Event Log ... >Here's the output of my batch file: ... Windows: General MVP ...
    (microsoft.public.win2000.cmdprompt.admin)