[英]how to get the details of USB devices connected to computer using java
我正在嘗試獲取連接到計算機的USB硬件設備的詳細信息,但我不知道Windows的本機代碼,因此可以使用JAVA獲取連接到計算機的硬件的詳細信息嗎?
vbscript代碼:
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代碼:
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();
}
現在,我正在嘗試使用此vbscipt代碼獲取詳細信息,但是當我執行此代碼時,出現錯誤,沒有找到腳本
嘗試使用JUsb。 此處的鏈接提供了簡單的示例。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.