• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 347
  • Last Modified:

Formatting Batch Script Output

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
Grime121
Asked:
Grime121
1 Solution
 
oBdACommented:
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
 
Grime121Author Commented:
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now