用Java关闭远程计算机 - 无法启动关闭但没有错误 [英] Shutdown Remote Computer in Java- Cannot initiate shutdown but no errors

查看:145
本文介绍了用Java关闭远程计算机 - 无法启动关闭但没有错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习java中的Runtime类,并且正在测试其中的命令行指令的使用。我试图使用Runtime.getRuntime()。exec(...)远程关闭计算机;当我运行它时,没有错误,但指定的机器没有关闭。我不知道为什么。

I am learning about the Runtime class in java, and am testing the use of command line instructions in it. I am trying to remotely shutdown a computer using Runtime.getRuntime().exec(...); When I run this, there are no errors, but the specified machine does not shut down. I don't know why.

代码:

import java.io.IOException;

class shutdownVirus {
    public static void main(String[] args) throws IOException {
        Runtime.getRuntime().exec("shutdown -m \\\\T12-LEOPARDIJ -s -t 10");
    }
}

任何帮助将不胜感激。
谢谢

Any help will be greatly appreciated. Thanks

推荐答案

尝试

Runtime.getRuntime()。exec(shutdown -s);

编辑部分:

使用此功能。

shutdown / s / m< Computer_Name> 关闭远程PC

这篇关于用Java关闭远程计算机 - 无法启动关闭但没有错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆