Latest topics
» JavaServer Faces (JSF)
Sat Sep 15, 2012 7:26 pm by vijayasarathy

» JAVA SERVERS
Wed Sep 12, 2012 6:34 pm by vijayasarathy

» 10 Best Java Web Development Frameworks
Wed Sep 12, 2012 6:18 pm by Prakash

» how to find hard disk serial details....
Thu Jul 05, 2012 1:08 pm by jagantech

» how to find MAC ID in windows using java
Thu Jul 05, 2012 1:03 pm by jagantech

» java server faces
Sat May 19, 2012 6:15 pm by jaganeshtech

» Oracle set to update analytics strategy, go after SAP customers
Sat Mar 24, 2012 12:06 pm by Naga

» Discovery over 'warp speed' planets
Sat Mar 24, 2012 12:32 am by plusinfomedia

» End of Java Era?
Sat Mar 24, 2012 12:03 am by plusinfomedia

External Links
External Links

how to find hard disk serial details....

Go down

how to find hard disk serial details....

Post  jagantech on Thu Jul 05, 2012 1:08 pm

package algorithm;

import java.io.File;
import java.io.FileWriter;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class DiskUtils {
public DiskUtils() { }

public static String getSerialNumber(String drive) {
String result = "";
try {
File file = File.createTempFile("realhowto",".vbs");
file.deleteOnExit();
FileWriter fw = new java.io.FileWriter(file);

String vbs = "Set objFSO = CreateObject(\"Scripting.FileSystemObject\")\n"
+"Set colDrives = objFSO.Drives\n"
+"Set objDrive = colDrives.item(\"" + drive + "\")\n"
+"Wscript.Echo objDrive.SerialNumber"; // see note
fw.write(vbs);
fw.close();
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();
}
return result.trim();
}

public static void main(String[] args){
String sn = DiskUtils.getSerialNumber("C");
System.out.println("hard disk serial number:"+sn);
}}

jagantech

Posts : 2
Join date : 2012-07-05

View user profile

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum