GeeCON Prague 2014*
The moose likes Distributed Java and the fly likes how to connect to remote pc to run a batch file in java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Distributed Java
Bookmark "how to connect to remote pc to run a batch file in java" Watch "how to connect to remote pc to run a batch file in java" New topic
Author

how to connect to remote pc to run a batch file in java

Nivedhitha Bhoopathi
Greenhorn

Joined: Nov 06, 2009
Posts: 8
hi all,
I want to run a batch file which resides in a remote pc using a java program.the thing is when i try to run it is asking login id and password for that remote pc(i have account to access that pc). I need to connect to the remote pc through a java program and run a batch file..so that ,i need not give login id and password every time i want to run that batch file...thanks in advance..
Nivedhitha Bhoopathi
Greenhorn

Joined: Nov 06, 2009
Posts: 8
Nivedhitha Bhoopathi wrote:hi all,
I want to run a batch file which resides in a remote pc using a java program.I must specify login id and password in that java program itself and connect that machine in which batch file resides and run it.so that every time i run that batch file i need not provide login id and pwd of that remote pc.could some one help me out.

Thanks in advance

Nivi
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12791
    
    5
What software are you allowed to put on the remote PC?

What operating system and what security is in place on the remote PC?

Bill
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
Sounds like you could put a RMI server on the remote PC and execute the batch file via Java object (on the remote PC).

Or, you could put a open-source Java application server on the remote PC and execute the batch file via Session EJB.
Nivedhitha Bhoopathi
Greenhorn

Joined: Nov 06, 2009
Posts: 8
hai

Thanks for your responses...
Remote PC is windows operating system.
but i dont have java technology installed in that pc in which batch file resides.can you be more elloborate on your answer.
concept wise i know rmi...and did implemented sample programs also on it..but cant get a clear picture for this particular requirement(running a batch file on remote pc) when i relate with rmi.
thanks in advance

Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
First, you would need to understand what a RMI Server is, and also how to create one. Second, you would need to install a Java Runtime Environment on the remote PC.

Once you do the above, you would create a business object that executes the batch file and link this to a RMI-based object living in the RMI server.

Hope this helps!


Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

There are other ways besides RMI. For example you could use Telnet to connect to the remote computer and run the batch file, but that would require a Telnet server on the remote computer. Or in some FTP implementations you can use FTP to run a command on the remote computer, but that would require an FTP server there.

You should also realize that allowing people to connect to your computer and run executable programs has security implications, in other words those people could do harm to your computer if you weren't careful about who you allowed to connect and what you allowed them to do. This means that the people who own that remote computer should be consulted about what methods of connection they will allow. So you should consult them before making any decisions at all. Perhaps they will prefer (or permit) only one method.
Nivedhitha Bhoopathi
Greenhorn

Joined: Nov 06, 2009
Posts: 8
hi

ya ok... will try accordingly..and will get back to you all..
Randi Randwa
Greenhorn

Joined: Feb 21, 2009
Posts: 7

Do you have biterscripting ( http://www.biterscripting.com ) installed on the remote computer ? If it is, you can use this approach. (If not, you can always download free.)

Anytime you want to execute a batch file on the remote system, create a batch file on that remote system at, say, C:/Testing/file.bat. (This can be done using shared folders. ). Then write the following bite script on that remote system.






Copy and paste the above script into a script file C:/Scripts/RemoteExec.txt, then invoke the script by scheduling the following command in task scheduler.







The above command can be called directly from a Java program if needed.









 
GeeCON Prague 2014
 
subject: how to connect to remote pc to run a batch file in java