DOS命令 :net user username newpassword
如何使用java远程连接到windows :https://blog.youkuaiyun.com/kerafan/article/details/50180103
改密代码:
import java.io.IOException;
import java.net.SocketException;
import com.autoOps.util.WindowsTelnetClient;
public class RemoteWinTest {
public static void main(String[] args) {
String hostname = "192.168.1.10"; // or:127.0.0.1
int port = 23;
String username = "username";
String password = "password";
String newPassword = "123456";
// password = "123456";
// newPassword = "password";
String changePwd = "net user %s %s";
WindowsTelnetClient client = new WindowsTelnetClient(hostname, port, username, password);
try {
System.out.print(client.connect());
changePwd = String.format(changePwd, username,newPassword);
System.out.print(client.sendCommand(changePwd)); // 执行windows命令
System.out.print(client.disconnect());
} catch (SocketException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}