Solved

Batch file for installed applications

Posted on 2004-04-14
16
8,847 Views
Last Modified: 2012-06-27
I hae two similar questions.


1 .Is it possible to run a batch file to simply place into a text document a list of all the applications installed on your computer

2. Is it possible to run a batch file to check that an particular application has been installed ?

Many thanks

GISVPN
0
Comment
Question by:gisvpn
16 Comments
 
LVL 65

Expert Comment

by:rockiroads
Comment Utility
To get a list of applications installed on your computer, you can do it by registry or directory

if you do by registry, you will proabably have to write some code (I can do it in VB but not in DOS)
with a directory, you can assume everything has been installed in C:\Program Files (this is the usual location, although it can be overridden)

then list all directories under that, but it gives you a directory name, not name of application


registry:
if you open up RegEdit then go to

HKEY_LOCAL_MACHINE
SOFTWARE
Microsoft
Windows
CurrentVersion
Uninstall

Open that branch and you will see a series of subbranchs, just click on each one and it gives you details of the applicaton installed

if you highlite Uninstall, then select menu Registry, Export Registry file, you can export all this info into a file (called .reg, just rename to .txt)

0
 
LVL 65

Accepted Solution

by:
rockiroads earned 250 total points
Comment Utility
If you dont know registry, I dont recommend you change anything, can cause major disasters if you play around with it
0
 
LVL 65

Expert Comment

by:rockiroads
Comment Utility
ok, how to export registry entries from command line

regedit /e <name of file.txt> "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
0
 
LVL 16

Expert Comment

by:_nn_
Comment Utility
Hi,

Based on rockiroads's idea, you could use VBS. There is an example at http://www.winnetmag.com/Files/07/39314/Listing_02.txt
(link found from http://www.winnetmag.com/WindowsScripting/Article/ArticleID/39314/39314.html )

I made some simple tests and it proved working. For exporting a listing in a text file, I just used

  > listapps.txt cscript ListApps.vbs

a oneliner you can easily plug into a batch file, which would solve your question 1. For Q 2., it's possibly just a matter of piping that output into a find command, something like

  cscript ListApps.vbs | find /I "Microsoft Windows 2000 Server Resource Kit"

which would check whether the resource kit is installed or not.
0
 
LVL 10

Expert Comment

by:Kavar
Comment Utility
GISVPN:

Yes on both accounts, but I think what you want should be accomplished using another means...

The problem as to whether or not a piece of software is installed has come up MANY times.  What does installed mean?  Does it mean the app works 100%?  If that is the definition you are looking for, one simple reg Query will not suffice.  If all you are looking for is if the application has at one time been installed AND it has not been officially uninstalled, then using

regedit /e c:\reg.txt "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"|findstr "{Software Name | Class ID}"
%b%=notinstalled
for /F %%a in (c:\reg.txt) do %b%=installed

2 special notes, do not use find on win2k and xp
now you have a variable in a batch that tells you whether or not your software is installed

The problem is that you have no Idea if the program is REALLY installed, for one, the uninstall key may not be populated but the application is still there  (happens a lot when a tech doesn't have install software and they are pressured into fixing an issue)  For 2, the application may be installed but "Damaged" to the point that it doesn't work.

What we have done to solve / get around this issue:
We use TSCensus and SMS2003 both of these provide very detailed informtation on software inventory.
0
 

Author Comment

by:gisvpn
Comment Utility
hello all and thanks for your comments :)


rockiroads

thanks this works well......however a little extra thing is that i would like to be able to filter out alot of the stuff it returns to the text file. I wish to only see what Hotfixes have been installed on the computer. They all contain the word HOTFIX somewhere in the display name... is it possible to only return the keys with the word HOTFIX somewhere in the display name ?


_nn_

thanks for the vbs however i cannot get it to work :(

Kavar

Sounds good, could i ask why cannot i not use find on Win XP and 2000 ? :) do you know how i can search for all the keys at  "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" which has the word HOTFIX somewhere in the display name ?
0
 
LVL 10

Assisted Solution

by:Kavar
Kavar earned 250 total points
Comment Utility
yeah#1 win2k and xp regedit exports in unicode find only works on ascii

yeah #2
type c:\reg.txt|findstr -i "hotfix" > C:\regResults.txt

-- I still would prefer to do these manipulations using more interactive methods, I can help you if you want a script for determining hotfixes...

0
 
LVL 65

Expert Comment

by:rockiroads
Comment Utility
Im not sure how to do it within regedit, you would need to know keys

there might be a filter within DOS to search for specific strings. I think its FIND

FIND /I "string to find" "filename"

where /I is ignore case
e.g.
find /i "hotfix" "myfile.txt"


Unix has grep which is a great utility but for a windows version, you can get a evalution version of wingrep http://www.wingrep.com
that might help u


0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 10

Expert Comment

by:Kavar
Comment Utility
there is both find and findstr
in this case as I said earlier, he will want to use findstr
0
 
LVL 65

Expert Comment

by:rockiroads
Comment Utility
sorry kavar, had the window open, checked on dos to see what is the search equivalent then posted, then I saw yours!

0
 
LVL 10

Expert Comment

by:Kavar
Comment Utility
no worries :)
0
 
LVL 65

Expert Comment

by:rockiroads
Comment Utility
Ive got win2k, couldnt find findstr,

you got unixy background?

type .. | ...

is more a unixy type stuff
0
 
LVL 10

Expert Comment

by:Kavar
Comment Utility
maybe its a resource kit tool (don't think so)

Yeah, I love unix, just waiting for the world to come around so I can get a high paying job as an IT manager over a unix shop

0
 
LVL 65

Expert Comment

by:rockiroads
Comment Utility
ha, Im a unix background as well, always preferred it and always will, but Ive been with Windows last few years, do miss Unix

cant do powerful shell scripting in Windows/Dos like you could with Unix

so sad, I even came across VI for Windows - now VI on Unix was a great editor!
0
 
LVL 10

Expert Comment

by:Kavar
Comment Utility
the power of VI and sed ....

takes so much on a bloat-dows system to get anywhere near that simple power...
0
 
LVL 65

Expert Comment

by:rockiroads
Comment Utility
not forgetting awk...
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
If you don't know how to downgrade, my instructions below should be helpful.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now