Link to home
Start Free TrialLog in
Avatar of gisvpn
gisvpnFlag for United States of America

asked on

Batch file for installed applications

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
Avatar of rockiroads
rockiroads
Flag of United States of America image

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)

ASKER CERTIFIED SOLUTION
Avatar of rockiroads
rockiroads
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ok, how to export registry entries from command line

regedit /e <name of file.txt> "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
Avatar of _nn_
_nn_

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.
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.
Avatar of gisvpn

ASKER

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 ?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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


there is both find and findstr
in this case as I said earlier, he will want to use findstr
sorry kavar, had the window open, checked on dos to see what is the search equivalent then posted, then I saw yours!

no worries :)
Ive got win2k, couldnt find findstr,

you got unixy background?

type .. | ...

is more a unixy type stuff
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

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!
the power of VI and sed ....

takes so much on a bloat-dows system to get anywhere near that simple power...
not forgetting awk...