Solved

Batch file for installed applications

Posted on 2004-04-14
16
8,851 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
ID: 10821484
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
ID: 10821489
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
ID: 10821512
ok, how to export registry entries from command line

regedit /e <name of file.txt> "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
0
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!

 
LVL 16

Expert Comment

by:_nn_
ID: 10822098
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
ID: 10822921
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
ID: 10823217
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
ID: 10823266
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
ID: 10823317
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
 
LVL 10

Expert Comment

by:Kavar
ID: 10823361
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
ID: 10823490
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
ID: 10823507
no worries :)
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 10823534
Ive got win2k, couldnt find findstr,

you got unixy background?

type .. | ...

is more a unixy type stuff
0
 
LVL 10

Expert Comment

by:Kavar
ID: 10823562
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
ID: 10823674
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
ID: 10824090
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
ID: 10824154
not forgetting awk...
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

713 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