Python Forum
help need with running python script on remote windows machine
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
help need with running python script on remote windows machine
#1
Hi all,

I am trying to run below python code for connecting remote windows machine from unix to run an python file exist on that remote windows machine..

Below is the code I am trying:
Code:
#!/usr/bin/env python
import wmi

c = wmi.WMI("xxxxx", user="xxxx", password="xxxxxxx")
process_startup = c.Win32_ProcessStartup.new()
process_id, result = c.Win32_Process.Create(CommandLine="C:\Python27\abtest.py")
if result == 0:
  print("Process started successfully: %d" % process_id)
print(result)
connection is established successfully. But its not executing the python script..
if i had to do it manually then on remote i will got c:\phhton27 manually then run at prompt like below
c:/python27> python abtest.py
How can I put above command in .Win32_Process.Create format.

please guide..
Reply
#2
My understanding of wmi is you cannot use it on linux, because it's a wrapper on a windows dll.
One way I see is to install cygwin, by this way you will have a linux emulation on your windows pc, et so you could be able to run a ssh server and eventually run python. Dirty, heavy, long, if it works.
May be openssh will give you a way to start a ssh server, good luck also to test it.
Another way, probably the best, is to start a python server process on windows (for instance, see : https://docs.python.org/fr/3/library/wsg...le-wsgiref), which can start other processes. It can be done by many ways, it depends of what you want. Tell us more.

Apologize, some package claims they are able to do wmi from linux.
But I didn't see them in the official packages, so take care of what they are and what they do exactly...
I wouldn't test it on own pc...
Reply
#3
hmm. yeah saw some google post wmi , the above code taken from that reference only... its not executing intended file
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Problem executing a script on a remote host tester_V 3 413 Sep-26-2021, 04:25 AM
Last Post: tester_V
  PsInfo from remote computer in python susja 1 493 Aug-10-2021, 08:02 AM
Last Post: DeaD_EyE
  Copying files from a remote Windows station tester_V 11 1,345 Jul-17-2021, 02:19 AM
Last Post: tester_V
  cant use ping, sudo or other commands in remote shell script. throwaway34 7 1,185 May-17-2021, 11:29 AM
Last Post: throwaway34
  Running script on multiple files Afrodizzyjack 1 902 May-14-2021, 10:49 PM
Last Post: Yoriz
  Python script on windows 10 shuts down TamP 2 981 Mar-08-2021, 07:19 AM
Last Post: TammyP
  Error when running script on startup in Linux NoahTheNerd 0 692 Mar-07-2021, 04:54 PM
Last Post: NoahTheNerd
  Refresh data in python script while running in Terminal frankenchrist 4 1,532 Feb-03-2021, 09:54 AM
Last Post: Larz60+
  [SOLVED] Requiring help running an old Python script (non Python savvy user) Miletkir 13 1,948 Jan-16-2021, 10:20 PM
Last Post: Miletkir
  Need help with 3 errors when running script pythoncoder999 3 1,105 Dec-19-2020, 04:04 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020