Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Nivedhitha Bhoopathi
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13056
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 20762
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi

ya ok... will try accordingly..and will get back to you all..
 
Randi Randwa
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.









 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic