java - How to get and change System password using servlet? -
i have system(windows) username , system(windows) current password , change current password new password using servlet code.
getting current windows password not possible. if jvm running under user account admin rights, can reset users password using processbuilder
class , windows net user
command.
processbuilder pb = new processbuilder("net", "user", "someusername", "somepassword"); process pro = pb.start();
to check result of command, read it's error stream , input stream of process
object returned exec
method.
bufferedreader bre = null; bufferedreader bri = null; try{ bre = new bufferedreader(new inputstreamreader(pro.geterrorstream())); bri = new bufferedreader(new inputstreamreader(pro.getinputstream())); pro.waitfor(); //wait command finish string line; while((line = bre.readline()) != null) system.out.println(line); while((line = bri.readline()) != null) system.out.println(line); } { if(bre != null) bre.close(); if(bri != null) bri.close(); }
Comments
Post a Comment