top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to execute command on remote windows machine using python

+1 vote
1,899 views

I have a requirement where I need to kill one process on remote windows machine. Following command just works fine if i have to kill process on local machine

os.system('taskkill /f /im processName.exe')

However I am not able to figure out how to execute this command on remote windows machine. So is there any way I can execute command from windows machine on remote windows machine ?
Note: my local machine is also windows (machine from where i have to execute command)

posted Sep 3, 2013 by Kumar Mitrasen

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

+1 vote

You are looking for information on "Remote Procedure Calls", or RPC.

There are obvious security implementations from enabling RPC, imagine if random people on the internet could shut down whichever processes they like on your machine. But having said that, there are a number of excellent RPC libraries for Python. Here are two which can be used

http://pythonhosted.org/Pyro4/
https://pypi.python.org/pypi/rpyc

answer Sep 3, 2013 by Seema Siddique
+1 vote

The simplest way is from your local machine. taskkill accepts a /s parameter which can specify a remote machine by IP or name.

http://technet.microsoft.com/en-us/library/bb491009.aspx

answer Sep 3, 2013 by Jagan Mishra
Similar Questions
+1 vote

My project required to execute a hadoop job remotely and the job requires some third-part libraries (jar files). I tried:
1. Copy these jar files to hdfs.
2. Copy them into the distributed cache using DistributedCache.addFileToClassPath so that hadoop can spread these jar files to each of the slave nodes.

However, my program still throws ClassNotFoundException. Indicating that some of the classes cannot be found when the job is running.

So I am lookinh:
1. What is the correct way to run a job remotely and programmatically while the job requires some third-party jar files.
2. I found DistributedCache is deprecated (Im using hadoop 1.2.0), what is the alternative class?

+2 votes

I have to do the following operation in python script

  1. Open a port using screen command, (USB COMPORT)
  2. execute a command
  3. wait for the result (next line of command)
  4. Compare the result
  5. Close the port
0 votes

I want to install sip on windows bit using python 32 bit.
I download sip from this link https://www.riverbankcomputing.com and I try to install from cmd line :

C:WINDOWSsystem32>cd C:UsersusernameDesktopsip-4.17

C:UsersusernameDesktopsip-4.17>python configure.py install
and take that error any idea ?

This is SIP 4.17 for Python 2.7.11 on win32.
Error: Unsupported macro name specified. Use the --show-build-macros flag to see a list of supported macros.

+3 votes

while i am connecting from my windows machine to mongoDB server running on remote windows machine.
I am getting the following error.

MongoDB shell version: 3.0.4
connecting to: 192.168.0.103:27017/test
2015-06-20T15:16:52.584+0530 W NETWORK Failed to connect to 192.168.0.103:27017
after 5000 milliseconds, giving up.
2015-06-20T15:16:52.589+0530 E QUERY Error: couldn't connect to server 192.16
8.0.103:27017 (192.168.0.103), connection attempt failed
at connect (src/mongo/shell/mongo.js:181:14)
at (connect):1:6 at src/mongo/shell/mongo.js:181
exception: connect failed

...