Solved

Formatting Batch Script Output

Posted on 2004-09-30
2
344 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 500 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

Comparison of Amazon Drive, Google Drive, OneDrive

What is Best for Backup: Amazon Drive, Google Drive or MS OneDrive? In this free whitepaper we look at their performance, pricing, and platform availability to help you decide which cloud drive is right for your situation. Download and read the results of our testing for free!

Question has a verified solution.

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

Numerous times I have been asked this questions that what is it that makes my machine log on so slow, there have been cases where computers took 23 minute exactly after taking password and getting to the desktop. Interesting thing was the fact th…
On July 14th 2015, Windows Server 2003 will become End of Support, leaving hundreds of thousands of servers around the world that still run this 12 year old operating system vulnerable and potentially out of compliance in many organisations around t…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

728 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