2

I am trying to get the details of USB hardware devices connected to computer but I don't know the native code of windows so is it possible to get the details of hardware connected to computer using JAVA Thanks in advance

vbscript code:

Set HDs = GetObject("winmgmts:(impersonationLevel=impersonate)")
Set colItem=HDs.ExecQuery("Select * from Win32_DiskDrive")
For Each hd In colItem
    Wscript.Echo hd.PnPDeviceID & "vigi"
Next

java code:

try {
    Process p = Runtime.getRuntime().exec("cscript //NoLogo " + file.getPath());
    BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
    String line;
    while ((line = input.readLine()) != null) {
        result += line;
    }
    input.close();
} catch(Exception e){
    e.printStackTrace();
}

now i'm trying to get the details using this vbscipt code but when i'm executing this code the error comes no script found

Maxbester
  • 2,435
  • 7
  • 42
  • 70
Vighanesh Gursale
  • 921
  • 5
  • 15
  • 31
  • There is already a post about this. Check [this][1] [1]: http://stackoverflow.com/questions/2980509/enumerate-external-drives – Prateek Jain Jan 02 '13 at 07:13
  • have you tried looking at the answers provided here? http://stackoverflow.com/questions/544507/how-to-communicate-with-a-usb-device-under-windows-and-java – radai Jan 02 '13 at 07:15
  • @PrateekJain @Radai, format for links in comments `[TEXT](URL)` :) – Matt Clark Jan 02 '13 at 07:19
  • i've used the vbscript to find the details of USB device but somehow i can't execute that vbscript the error comes no scrpit found – Vighanesh Gursale Jan 20 '13 at 09:26

1 Answers1

1

Try using JUsb. The link here provides simple example.

Jayamohan
  • 12,734
  • 2
  • 27
  • 41