I want the java code that executes .bat file remotely

October 4, 2012 at 23:37:22
Specs: Windows XP
.bat file not executed remotely using java
here iam using the code like the following
Process process=Runtime.getRuntime().exec("/cmd /c start \\\\<Host_Name>\\<Shared_Folder_name>\\BatFileName.bat");
Instead of executing the remote computers shared folders .bat file it is executing my local computers .bat file any help please

See More: I want the java code that executes .bat file remotely

Report •

October 5, 2012 at 04:20:38
Have I understood your question correctly - that you expect the batch file to run on the remote machine?

It doesn't matter where you get the batch file from, you are executing "cmd" on the local machine and thus the batch file is running (under the "cmd" interpreter) on the local machine.

I'm not even sure that Java, with the security constraints built into it, would allow you to do what you want to. I would hope that it wouldn't as it would be quite a security risk.

Report •

October 5, 2012 at 04:36:07
Hai IJack,
Yes,The .bat file will be executed in the remote computer's[Test_Server] shared folder instead of that it is running on the local.

Report •

October 5, 2012 at 04:42:12
Well, as I said, it won't run remotely. To do that you would have to run the command processor on the remote machine. I'm not sure that Java allows you to do that. I'm sure you can appreciate the problem with a program that allows you to run arbitrary programs on a remote computer.

Report •

Related Solutions

October 5, 2012 at 12:37:43
An alternative is to spawn an instance of psexec or wmic to create a process on the remote machine via Java.


Report •

Ask Question