java 中未设置 psexec 进程:"cannot find the file specified"
psexec process not set in java: "cannot find the file specified"
我正在尝试 运行 一些代码,但出现错误:
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();
现在我遇到了这个错误:
Exception in thread "main" java.io.IOException:
Cannot run program "psexec.exe":
CreateProcess error=2, The system cannot find the file specified
需要更改什么才能使此代码正常工作?
程序 psexec.exe 不在您的 java 进程的 PATH 变量中。
尝试使用完整路径启动 .exe 文件或将 psexec.exe 所在的目录添加到您的 PATH 环境变量中。
我正在尝试 运行 一些代码,但出现错误:
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();
现在我遇到了这个错误:
Exception in thread "main" java.io.IOException:
Cannot run program "psexec.exe":
CreateProcess error=2, The system cannot find the file specified
需要更改什么才能使此代码正常工作?
程序 psexec.exe 不在您的 java 进程的 PATH 变量中。
尝试使用完整路径启动 .exe 文件或将 psexec.exe 所在的目录添加到您的 PATH 环境变量中。