top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration
Print Preview

How to execute command on remote windows machine using python

+1 vote
950 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 Google+ Share Button LinkedIn Share Button Multiple Social 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

+3 votes

I'm new to Python. I downloaded the 64-bit build of Python 2.7.10 from www.python.org/downloads/release/python-2710. I run Windows 7 Pro on a Dell PC.

I find that the installation package creates a folder called "Python 2.7" in my Start menu, with both a command prompt and IDLE GUI options.

I hold my scripts in another directory that is parallel to but not under the one where Python 2.7 resides, so I set the Environment Variable PYTHONPATH to include the directory where my scripts reside. Unfortunately, I am unable to reach them in either the IDLE GUI or the "Python command line" in that folder in my start menu. The only way I have managed to run Python scripts is to open an ordinary command prompt from Accessories, navigate to the directory with the scripts, and run python from the command prompt in that directory.

Can anyone let me know what I'm not doing that I should be doing to run Python and my scripts from the parallel directory under the GUI or the command line from the start menu folder ?


Useful Links with Similar Problem
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#470/147, 3rd Floor, 5th Main,
HSR Layout Sector 7,
Bangalore - 560102,
Karnataka INDIA.
QUERY HOME
...