I am trying to run some code, but I get an error:
String strCmd = "psexec.exe \\server -u use -p aaa tasklist";
Process process = Runtime.getRuntime().exec(strCmd);
BufferedReader stdout = null;
stdout = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line;
for(int l = 0; ( line = stdout.readLine()) != null; )
{
System.out.println ("output ->"+line);
}
stdout.close();
BufferedReader stdErr = new BufferedReader(new InputStreamReader(process.getErrorStream()));
for(int l = 0; (line = stdErr.readLine()) != null; )
{
System.out.println ("Error Output ->"+line);
}
stdErr.close();
And now I am facing this error:
Exception in thread "main" java.io.IOException:
Cannot run program "psexec.exe":
CreateProcess error=2, The system cannot find the file specified
What do need to change to make this code working?