Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-11-2009, 11:42 PM
Member
 
Join Date: Feb 2009
Posts: 2
Rep Power: 0
Lukalo is on a distinguished road
Default Detecting software installed in PC
Hi everyone

Im trying to make a program that detects all the software installed in the computer, however i've got no clue where to start, i tried searching here and in google but didnt find anything about this topic (Perhaps i didnt use the correct keywords/search terms). so if anyone knows something or know where to find about it, that information will be most apreciated.

and for the curious.., im trying to develop this tool in order to be able to keep an inventary of my software vs my licenses, so my little company wont get in big troubles.

Lukalo
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 02-12-2009, 08:30 AM
Senior Member
 
Join Date: Jan 2009
Posts: 355
Rep Power: 2
toadaly is on a distinguished road
Default
There are already inexpensive commercial products that do this for you, but if you insist on writing one yourself, I probably wouldn't use Java since it has no hooks into the Windows API calls that give you this information.

However, you can exec the "reg query" command from java. Here is a crappy example with no error checking etc.

Code:
import java.io.*;

public class junk {

    public static void main(String[] args) throws Exception {

      String cmd = "reg query \"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft"+
           "\\Windows\\CurrentVersion\\Uninstall\"";

      // This one will show you  software categories installed
      //String cmd = "reg query \"HKEY_LOCAL_MACHINE\\Software\"";

      Process p = Runtime.getRuntime().exec(cmd);
      
      Thread.sleep(2000l); //terrible, the right way is p.waitFor
      
      //p.waitFor();  /* this command sometimes hangs on windows !!!???*/

      InputStream in = p.getInputStream();

      byte[] bytes = new byte[16384];

      StringBuffer buf = new StringBuffer();

      while(true) {
	  int num = in.read(bytes);

	  if(num == -1) break;

	  buf.append(new String(bytes,0,num,"UTF-8"));
      }

      System.out.println(buf.toString());

      p.destroy();

    }

}
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 02-12-2009, 03:07 PM
Member
 
Join Date: Feb 2009
Posts: 2
Rep Power: 0
Lukalo is on a distinguished road
Default
@ Toadaly
Thanks for the code... it gave me some good hints at where to get started....

@ artonlinehome
???? it does?... well nothing happened here.... perhaps a Vista Bug?? XD

Anyway thanks for the help
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 02-13-2009, 04:04 AM
Senior Member
 
Join Date: Jan 2009
Posts: 355
Rep Power: 2
toadaly is on a distinguished road
Default
Originally Posted by artonlinehome View Post
dont do this , it will delete all reg keys
Uh. No it won't. Please don't scare people without knowing what you're talking about.
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Running a jar after it's installed Doctor Cactus New To Java 7 01-20-2009 12:08 PM
Installed Certificate List mwalstra Advanced Java 0 12-09-2008 01:53 PM
Getting Installed Look And Feels Java Tip javax.swing 0 06-26-2008 08:45 PM
java code for checking if a software is installed or not heggemony Advanced Java 1 07-31-2007 02:19 PM
cannot find a JVM installed tommy New To Java 2 07-29-2007 09:23 PM


All times are GMT +2. The time now is 12:01 AM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org