Pankaj Dagar
Pankaj Dagar

Reputation: 87

I want to run a batch file present on my remote computer

I want to run a batch file present on my remote computer but I am getting an error that you don't have permission to access the share.

errorcode--: 0x80070035 the network Path was not found

Please help me out

Thanks in advance

public class Remotly {

    public static void main(String arr[]) {
        String cmd;
        try {
            Process r = Runtime.getRuntime().exec("cmd /c start \\\\xx.xx.xx.xx\\D:\\batch\\sas.bat");
        } catch (Exception e) {
            System.out.println("Execution error");
        }
    }
}

Upvotes: 0

Views: 370

Answers (1)

Thomas Weller
Thomas Weller

Reputation: 59564

The UNC path is incorrect, it contains a drive letter.

\\\\xx.xx.xx.xx\\D:\...

Instead, the folder must be shared by a name

\\\\xx.xx.xx.xx\\DriveD\...

To use it, you must map the network drive before, e.g. via

net use * \\\\xx.xx.xx.xx\\DriveD <Password> /User:<Username>

Upvotes: 1

Related Questions