?
Solved

Formatting Batch Script Output

Posted on 2004-09-30
2
Medium Priority
?
345 Views
Last Modified: 2010-04-19
I am using this command to put all of the names of the installed programs into a file: reg.exe query HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall /s | find "DisplayName" > SftWrInv_%computername%.txt

The problem is I need to remove everything on these lines except the actual program names. I'd like to have all the names on one line seperated by commas with no spaces as well. Here is a sample of the output as it is right now (the whitespaces are tabs):

    DisplayName      REG_SZ      Fathom
    DisplayName      REG_SZ      Microsoft Data Access Components KB870669
    QuietDisplayName      REG_SZ      Microsoft Data Access Components KB870669
    DisplayName      REG_SZ      LiveUpdate 1.80 (Symantec Corporation)
    DisplayName      REG_SZ      Macromedia Shockwave Player
    ParentDisplayName      REG_SZ      Windows XP - Software Updates

I don't know much about how to format text like this in a batch program. Anyone have an idea as to how I can do this? Thanks for your input.
0
Comment
Question by:Grime121
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 85

Accepted Solution

by:
oBdA earned 2000 total points
ID: 12194518
Something like that? This will set the variable "Programs" to a comma-separated list of the program names:

====8<----[Programs.cmd]----
@echo off
setlocal enabledelayedexpansion
set UninstallKey=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall

set Programs=
for /f "tokens=2*" %%a in ('reg.exe query %UninstallKey% /s ^| find /i "Displayname"') do (
  echo %%b
  set Programs=!Programs!,%%b
)
set Programs=%Programs:~1%
echo %Programs%
====8<----[Programs.cmd]----
0
 
LVL 1

Author Comment

by:Grime121
ID: 12194992
Man, with all the batch script stuff you've written for me in the past few weeks maybe I should be giving you a paycheck :P

Thanks again.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This may not be a text book method to resolve VSS backup issues but it seemed to have worked on few of the Windows 2003 servers we had issues while performing a Volume Shadow Copy backup. If you have issues while performing a shadow copy backup usin…
Learn about cloud computing and its benefits for small business owners.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question