Parsing file using FOR command not working correctly

From: Dave Pink (tron9901_at_msn.com)
Date: 07/12/04


Date: 12 Jul 2004 09:08:01 -0700

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.

Here's my batch file:

FOR /F "tokens=1 delims=[]" %%a in (hotfix.txt) DO SET Number=%%a
@ECHO %Number%

Here's the output of my batch file:

C:\>FOR /F "tokens=1 delims=[]" %%a in (hotfix.txt) DO SET Number=%%a

C:\>set Number=3166

C:\>set Number= Type: INFORMATION

C:\>set Number= Computer: PRDW2K-WEB109

C:\>set Number= Time: 6/27/2004 2:02:37 AM ID: 4377

C:\>set Number=Windows 2000 Hotfix KB837001 was installed.

Windows 2000 Hotfix KB837001 was installed.

How can I set the variable "Number" equal to "3166"? Any help would be
appreciated. Thanks.

Dave



Relevant Pages

  • Re: event log error
    ... > I'm getting this message in the event log, ... > Microsoft has a hotfix, does anyone have it that they can ... > Windows cannot unload your registry file. ... The hotfix may not solve your problem even when you get it. ...
    (microsoft.public.win2000.registry)
  • "Windows Explorer has encountered a problem and needs to close"
    ... At start-up, Windows appears to load normally; ... This Event log is also pasted below. ... Microsoft Product Support Services to report this error. ... 72772476 KB available on disk. ...
    (microsoft.public.windowsxp.basics)
  • Re: Install / Reinstall / Recovery Console causes shut down
    ... View and Manage Event Logs in Event Viewer in Windows XP ... the problem only occurs when the windows file structure is being ... nothing in the event log.. ... start the install process.. ...
    (microsoft.public.windowsxp.perform_maintain)
  • Cannot Open Control Panel
    ... I'm running Windows XP SP1 Home Edition. ... This Event log is also pasted below. ... Event Type: Error ... 72772476 KB available on disk. ...
    (microsoft.public.windowsxp.help_and_support)
  • Re: Remote Desktop Re-Connect
    ... does not include Windows 2003 or Windows Server. ... available target OS's are appropriate for Windows Server 2003 SE SP1? ... but my recollection was that the key is to look for event log errors at the ... remote session, and my local printer is not. ...
    (microsoft.public.windowsxp.work_remotely)

Loading