I want to open a file on remote windows machine from my local windows machine. The file should be visible on remote machine only.
My problem is, I should open a bat file on remote pc which creates access to do something like opening browser etc.
I did using PSExec to run the bat file remotely. Everything looked good, but when i try to open the browser on remote pc, it does not open browser but shows browser processes in task manager.
When I go and open that bat file manually on remote machine everything works fine. Browser opens and my work is done.
But I want to do that from my local machine especially from the command line. So that I can use this commands in Java.
Please help. If question is not clear please ask for more info.
Try using the -i option with psexec or specifying a session ie. -i 1
From the psexec manual.
'-i Run the program so that it interacts with the desktop of the specified session on the remote system. If no session is specified the process runs in the console session.'
example:
C:\SysinternalsSuite\psexec.exe \remotecomputer -u DOMAIN\administrator -p adminpass -i 1 "\remotecomputer\c$\Program Files (x86)\Google\Chrome\Application\chrome.exe" http://tinyurl.com/6fbgntx
I'd suggest you to use WMI - It management instrumentation. It allows running process on remote machine (obviously if you have enough permissions).
You can either access WMI from Java using one of popular interoparability libraries (JaWin, JInterop, JIntegra) or write JScript or VBScript and execute it from java.
JaWin and Jinterop are open-source. JIntegra is not.
JaWin requires windows OS on client machine. JIntegra and JInterop can be executed from other OS.
I used all 2 suggested methods and all 3 libraries. Probably now I prefer JInterop.
Related
My requirement is to automate an esxi remote machine using java.
So, I am able to automate vmware workstation and fusion by creating a bat file where I have added all the vmrun commands and executing the bat file using java.
Can anyone help me in achieving the same for esxi remote machine where I am using commands (like vmrun) for opening a browser in remote machine and passing the url.
I think vmrun utility is no longer supports for esxi.
powercli module of powershell solved my problem
Background: I am trying to run some Java code on a few target machines (to check registry values using JNA) and I don't want to have to install Java on every machine I need to check. I thought that a possible solution was having the server running the Java app use a batch file that lives on the local server. This batch file would simply call a Java program and get the data I needed from the remote machines.
Question: I have a local batch file that I am executing using Java. This batch file will remote execute on target machines. The batch file calls/runs a Java program. Is it possible for that Java program to live on the main server or does it need to live on the target machines as well?
if understood right, you could just say to the batch file to print a report of registry info that you are searching, then use java to directly reach that report, and then you could "analyze" that code in your "server"
with this you don't need to have java installed on local machine, and you don't need to launch "application" but simply: a script.
I configured a job for doing GUIAutomation(which got developed using java code including running commands and keyboard events) in the targeted machine.
Extra Info:-
I am running a command to launch the installer(installer GUI should come).....but its not happening
When I got any error I am capturing a image using JAVA DefaultToolkit API, but very time its coming as Black, nothing there to watch.
GUIAutomation tool was developed by myself.
Please help me to overcome this problem, since I have to automate it through jenkins.
Usually, problems running GUI programs in Jenkins occur because of the Jenkins service not having privileges to access the display of the slave (or master, you don't mention which) that is running the job. A typical solution is to start the slave via JNLP, which requires logging on to the slave, navigating to the slave's page on the jenkins master (via browser on the slave) and launching the slave process via the button on that page. You can also launch using the javaws command which will be shown on the same page.
On Windows slaves running as a service, you may have success by configuring the service to run as a user with login and desktop privileges for the slave - the default is the Local System user which has no such rights.
I have done the same job as you.
You have to create the jnlp connection. I create one batch file in slave machine such as: jar -jar slave.jar -jnlpurl (your url)/slave-agent.jnlp
If it's remote slave, it's better to use VNC instead of remote desktop when you operate that machine. Because when you close the session, remote desktop will hold the session, so the screenshot would be black.
Solution?
-- it looks like i may be able to use the x-11 forwarding in jsch and and use the java Desktop class to launch a file browser. Not sure if this will work.
What I am trying to do is, within a java application, open a connection to a server or another computer. I have found a way to do this that opens a terminal window but what I want is a gui/explorer/finder like window that allows me to drag and drop files between the machines.
--Edit--
An example: When i use an sftp application i can open a graphical window and drag files from my computer to folders on the remote server. just like an explorer or finder window. I am looking for a way to implement this type of functionality in java. I want to open a connection to a remote machine, then open a graphical window to browse the file system
You can use JSch to communicate with the server through SSH and
1. create your own GUI or
2. use X11 forwarding
you need two applications in each machine ,you can do this by TLS connection.
however it need a waiting thread in costumer machine (dragable) to get file from Tls port and stream it to new location or if you want to use just gui in one machine you can old applet or java Fx instead .
I have a program that needs to read/write files to/from a network computer. Sometimes however the program cannot access the folder on the network computer. Currently, to fix this issue, I go into windows explorer's network section, click the computer, enter my credentials, and then my program is able to read and write to this computer without a problem. Is there a way to allow Java to ask for these credentials or a way to automatically send these credentials using java? I am using Win7 and Win7 embedded on the network computer.
You can use http://jcifs.samba.org/ which is a library for accessing remote CIFS shares. This allows you to set username and password and works on any platform (not just windows) It works without needing to mount a drive.