[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Formatting Batch Script Output

Posted on 2004-09-30
2
Medium Priority
?
346 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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

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…
This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

656 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