gpt4 book ai didi

java - 为什么在远程系统上运行批处理文件时出现 "Path not correct"错误?

转载 作者:行者123 更新时间:2023-12-01 16:12:32 26 4
gpt4 key购买 nike

我需要从本地计算机在远程系统上运行批处理文件。使用下面的代码,我收到以下错误:

Path not correct

我有机器的 IP 地址,并且我已将批处理文件作为公共(public)共享提供,共享名称为 dsc

机器的IP地址是16.181.37.28。

这是我的代码。我知道道路是错误的。我怎样才能给出确切的路径?

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

/**
*
* @author padmaja
*/

import java.io.*;
class Test{
public static void main(String arg[]){
try{
String command = "cmd /C start 16.181.37.28/dsc/StartVisTsDataCenterMySql-log.bat";
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec(command);

}catch (IOException e) {
e.printStackTrace();
}
}
}

最佳答案

您是否尝试在远程计算机或本地计算机上运行脚本?您的方法将从远程计算机读取文件,但在本地计算机上运行它。

在远程计算机上运行某些内容的常用方法是让远程计算机上有一个进程永久运行并监听请求。如果请求到达,此过程将启动您想要运行的批处理文件。

关于java - 为什么在远程系统上运行批处理文件时出现 "Path not correct"错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/499013/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com