Results 1 to 4 of 4
  1. #1
    Lukalo is offline Member
    Join Date
    Feb 2009
    Posts
    2
    Rep Power
    0

    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

  2. #2
    toadaly is offline Senior Member
    Join Date
    Jan 2009
    Posts
    671
    Rep Power
    6

    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.

    Java 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();
    
        }
    
    }

  3. #3
    Lukalo is offline Member
    Join Date
    Feb 2009
    Posts
    2
    Rep Power
    0

    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

  4. #4
    toadaly is offline Senior Member
    Join Date
    Jan 2009
    Posts
    671
    Rep Power
    6

    Default

    Quote 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.

Similar Threads

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •