New Destiny
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Latest topics
» JavaServer Faces (JSF)
how to find hard disk serial details.... EmptySat Sep 15, 2012 7:26 pm by vijayasarathy

» JAVA SERVERS
how to find hard disk serial details.... EmptyWed Sep 12, 2012 6:34 pm by vijayasarathy

» 10 Best Java Web Development Frameworks
how to find hard disk serial details.... EmptyWed Sep 12, 2012 6:18 pm by Prakash

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

» how to find MAC ID in windows using java
how to find hard disk serial details.... EmptyThu Jul 05, 2012 1:03 pm by jagantech

» java server faces
how to find hard disk serial details.... EmptySat May 19, 2012 6:15 pm by jaganeshtech

» Oracle set to update analytics strategy, go after SAP customers
how to find hard disk serial details.... EmptySat Mar 24, 2012 12:06 pm by Naga

» Discovery over 'warp speed' planets
how to find hard disk serial details.... EmptySat Mar 24, 2012 12:32 am by plusinfomedia

» End of Java Era?
how to find hard disk serial details.... EmptySat 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.... Empty how to find hard disk serial details....

Post  jagantech 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

Back to top Go down

Back to top


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