import java.util.Scanner;
public class GetMachineSerialNumber
{
public static void main(String[] args)
{
try
{
Process process = Runtime.getRuntime().exec(new String[] { "wmic", "bios", "get", "serialnumber" });
process.getOutputStream().close();
Scanner sc = new Scanner(process.getInputStream());
String property = sc.next();
String serialnum = sc.next();
System.out.println(property + ": " + serialnum);
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
OUTPUT: SerialNumber: L908230
public class GetMachineSerialNumber
{
public static void main(String[] args)
{
try
{
Process process = Runtime.getRuntime().exec(new String[] { "wmic", "bios", "get", "serialnumber" });
process.getOutputStream().close();
Scanner sc = new Scanner(process.getInputStream());
String property = sc.next();
String serialnum = sc.next();
System.out.println(property + ": " + serialnum);
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
OUTPUT: SerialNumber: L908230
Can U pls explain the code?
ReplyDelete