Executing .bat file remotely from Linux box - user-interface

I'm trying to execute a .bat file on a windows box remotely from a Linux box by connecting via ssh, obtaining windows command prompt and then executing the batch file.
When I connect to the windows machine I can see that the process is running but the graphical interface is not being invoked.
Regards
Rahul

Probably, you need to install x server on windows? Consider for xming as one option. I am assuming that you have installed ssh-server on windows system.
NOTE: You need to login on the windows box (once, after windows login), start the x server on windows & then onwards you should be able to ssh to the system & start the GUI application.
Another possible issue:
The ssh-server binary should be executed by the user, after logging in once after the windows system boot. Then ssh to that windows box, export DISPLAY=:0 & run GUI app.
NOTE: I have not tested any of the above 2 solution, but these are what I think as possible solutions.
One more solution:
Create a dedicated TCP based server (on windows) client (on linux) model & send commands over that channel. A dirty way & would be able to give limited functionality, but it is tested to be working.

Related

Send command from batch shell to shell

My structure looks like this:
I have one Windows PC which is running 24/7 in my cellar and I have one Windows PC in my office (at home). Both are in the same network and I have admin privileges on both.
How can I set up a batch-file on my office PC which can send a command to the other PC through the command line? I should be able to turn off and reconnect my office PC without running every time in my cellar.
The SHUTDOWN command can remotely turn off other computers on your network but I am not sure what you mean by reconnect.
Have you taken a look at the tools described here ? If you are not on the latest version (or rather server version) of Windows, then you might have to download the tools mentioned here.
http://network-shutdown.com/remotely-shutdown-computers-on-network

How to start a program over RDP on windows 7

I want to start a command(cmd file) on remote windows 7/2008 hosts via rdp connection.
If it possible I want to operate from linux and python. If not - I can use windows.
So I have access to windows machines only via rdp. I have to start commands in automatically mode. What is the easiest way?
Don't.
Use WinRS, which is the proper solution for remote execution on Windows. See Using WinRS.
There are hacks to allow RDP to execute something remotely (eg. Can RDP clients launch remote applications and not desktops), they are hacks. RDP does not have remote execution facilities.
If you want a Linux client, then install an SSH server on your Windows images. If you're brave you could give OpenWSMAN a shot, but frankly I'd stick to ssh.

Is it possible to write a script to run an application on Windows VM from your mac?

I am using a RDC Connection from my mac to connect to an application (on windows box) in client network. Is that possible to write a script which does the following:
Open ur RDC. (i am using CoRD for this where my VM credentials are saved in .rdp files.
Login to VM with valid credentials from your .rdp file.
Open your app on that VM (for ex: IE explorer)
Following code in my shell script will connect me to my VM.(First two steps are working)
open rdp://[username[:password]#]hostname
How should I automate third step?
Is there any other way than shell script?
If you install Jenkins on your Mac, then install the Jenkins slave agent on the Windows machine, you can remotely run any command you like on the Windows box via the Jenkins web UI, and get back the results as well. In that scenario there's no need to use RDC at all.
For some more background, see: https://wiki.jenkins-ci.org/display/JENKINS/Distributed+builds
This might be a simplistic answer, but AutoHotKey is something that will automate your 3rd step. Its free and pretty easy to script. You can have this in your start up routine for your VM, so when you log in, you can have this kick off your job.
I have used it before for testing some Java Swing components on Windows and its been pretty handy (Windows was running on a Virtualbox VM on my Mac).

How to ask a remote windows machine to automatically launch an application?

I have a windows server 2003 up in the internet.
But sometime I need to restart it.
After restart, I want one of the applications to run.
I want to do this all programatically.
I can now remotely restart the server.
But the question is how can I ask that piece of software to be executed (more precisely, I want to execute a .BAT file to ask a tomcat to run)?
Because I don't want to manually log in to the machine and start that application. That is time consuming. Is there any possible way, once the machine is started, my application will be run as well?
If you're developing an application that should always be running on the server, you probably need to implement it as a Windows service. For C#, see the classes in the System.ServiceProcess namespace -- you will need to inherit from ServiceBase.
Alternatively, you can set the program to be run as a scheduled task on boot. See the Task Scheduler API to do this.
You can install Cygwin and then do it the same way we'd do it on a Linux box: via ssh, using keys.
OpenSSH is not part of the default Cygwin install, so be sure to select it. It's in the Net category.
Then, after you've installed Cygwin and sshd, read /usr/share/doc/Cygwin/openssh.README to learn how to set up sshd as a service, so it will answer requests automatically, without you having to start the ssh daemon manually.
Finally, set up keys, as described in the link above.
Part of the ssh protocol is a way to ask a remote machine to launch a program. Setting it up with keys lets you do it without needing a password.
You could try xCmd, which is a freeware app to run a command on a remote machine.

Invoking windows batch file from Linux

I have an application running only on Windows and a batch file that launches it.
I want to invoke this batch file from Linux, meaning something like Linux batch will launch the windows batch with parameters and this in its turn run my application.
Can I do that? How?
You could install an ssh server in the windows box (Cygwin has one), then from linux do something like:
ssh user#windows-box c:/path/to/batch.cmd
and that should launch your application in the windows box.
The most direct way is probably to install an ssh server on the windows box. Cygwin includes an ssh server.
Depending on how precise your timing needs are, you might be able to have an "at" job on the windows box that runs periodically (every 5 minutes?) and runs if it sees that a particular file exists, deleting the file. Then you could use Samba/smbclient to create the file. You would need to turn on filesharing on the windows box for this to work.
If the windows box has a web server, you could write a CGI, and trigger it using wget or cURL.
Our build process currently goes the other way: a windows sever kicks off things on the Linux server using plink (part of PuTTY). You might be able to set something similar up.
This may cause a security issue. Our information security person did not allow me to invoke any programs directly.
The safer way is to set up server on Windows computer. This can be a web-server for example. And then invoke your process inside PHP/Perl/Python script.
Also look at winexe that allows you to execute windows commands/batch scripts without running ssh server.

Resources