Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to execute command on remote windows machine

1,065 views
Skip to first unread message

gauran...@gmail.com

unread,
Sep 3, 2013, 12:45:57 AM9/3/13
to
Hi Guys,

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.

Note: my local machine is also windows (machine from where i have to execute command)

so is there any way i can execute command from windows machine on remote windows machine ?

Steven D'Aprano

unread,
Sep 3, 2013, 1:19:13 AM9/3/13
to
On Mon, 02 Sep 2013 21:45:57 -0700, gaurangnshah wrote:

> so is there any way i can execute command from windows machine on remote
> windows machine ?

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 I have (briefly) used:

http://pythonhosted.org/Pyro4/

https://pypi.python.org/pypi/rpyc



--
Steven

alex23

unread,
Sep 3, 2013, 1:33:17 AM9/3/13
to
On 3/09/2013 2:45 PM, gauran...@gmail.com wrote:
> 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.

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

gauran...@gmail.com

unread,
Sep 3, 2013, 2:45:38 AM9/3/13
to
Hi alex

I tried the command you suggested however it is giving me following error.

ERROR: The RPC server is unavailable.

Jean-Michel Pichavant

unread,
Sep 3, 2013, 5:44:01 AM9/3/13
to gauran...@gmail.com, pytho...@python.org

----- Original Message -----
> Hi alex
>
> I tried the command you suggested however it is giving me following
> error.
>
> ERROR: The RPC server is unavailable.

Hi,

Please do not top post :)
If python is installed on the remote machine, using execnet http://codespeak.net/execnet/ is very easy. Its only requirement is python being installed on both machines.

JM


-- IMPORTANT NOTICE:

The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

rand...@fastmail.us

unread,
Sep 3, 2013, 8:39:18 AM9/3/13
to gauran...@gmail.com, pytho...@python.org
The taskkill command actually has an option for this: /S. I don't know
what mechanism it uses or what you would have to do to give yourself
permission to use it.


--
Random832

Jean-Michel Pichavant

unread,
Sep 3, 2013, 9:57:22 AM9/3/13
to Gaurang shah, python-list

----- Original Message -----

> I tried it, however it seems really complicated.

> If you have used it before, can you show me how can i do it ?

> Gaurang Shah
> Blog: qtp-help.blogspot.com
> Mobile: +91 738756556

Please don't ask question off-list.

It's not complicated at all.

The documentation has a lot of examples:
http://codespeak.net/execnet/example/test_info.html#execute-source-code-in-subprocess-communicate-through-a-channel

makegateway by defaut execute the code on the local machine. You simply need to use something like
makegateway("ssh=myRemoteMachine")

cheers,

88888 Dihedral

unread,
Sep 3, 2013, 10:21:11 AM9/3/13
to
gauran...@gmail.com於 2013年9月3日星期二UTC+8下午12時45分57秒寫道:
This is trivial. First install the VNC on the remote site and
make sure your VNC is working in the proper forground.

Just write a mouse/keyboard emulator service on the remote site
with the propper port opened by python scripts.

Use the control computer to send commands to the remote site.

This scheme will work under unix-linux-windows OS.

Message has been deleted
0 new messages