Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Markdown and HTML are turned off in code blocks:
- <i>This is not italic</i>, and [this is not a link](http://example.com)
- void hddName(String ip) {
- try {
- String commands="cmd /c wmic.exe DISKDRIVE get name";//HDD Details
- //System.out.println({"CMD", "/C", "WMIC OS GET Installdate,SerialNumber"});
- Process process = Runtime.getRuntime().exec(commands);
- process.getOutputStream().close(); //Closing output stream of the process
- System.out.println();
- StringBuilder sb=new StringBuilder();
- //Reading sucessful output of the command
- BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
- while ((s = reader.readLine()) != null)
- {
- sb.append(s).toString();//append output
- }
- System.out.println("result"+sb);//gives result with null keyword
- String ss=sb.toString();//gives result with null keyword
- System.out.println("result"+ss);
- try{
- System.out.println(s);
- Connection conn;
- Statement stmt;
- Class.forName("com.mysql.jdbc.Driver");
- conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/system","root","");
- stmt= conn.createStatement();
- String sql="update sys set hdname='"+ss+"' where ip='"+ip+"'";// save null to mysql database
- int val= stmt.executeUpdate(sql);
- conn.close();
- stmt.close();
- }
- catch(Exception e)
- {
- }
- // Reading error if any
- reader = new BufferedReader(new InputStreamReader(process.getErrorStream()));
- while ((s = reader.readLine()) != null)
- {
- System.out.println(s);//any error
- }
- }
- catch (IOException e)
- {
- e.printStackTrace(); //TODO: necessary exception handling
- }
- // return s;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement