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
  No Internet connection when running a Python script basil_555 8 439 Mar-11-2024, 11:02 AM
Last Post: snippsat
Question Running Python script through Task Scheduler? Winfried 8 335 Mar-10-2024, 07:24 PM
Last Post: Winfried
  Triggering a ps1 script in remote windows server via http python request jasveerjassi 1 316 Jan-26-2024, 07:02 PM
Last Post: deanhystad
  Help Running Python Script in Mac OS emojistickers 0 306 Nov-20-2023, 01:58 PM
Last Post: emojistickers
  Trying to make a board with turtle, nothing happens when running script Quascia 3 607 Nov-01-2023, 03:11 PM
Last Post: deanhystad
  i tried to install python for the first time today and pretty certain im being remote brianlj 2 505 Oct-03-2023, 11:15 AM
Last Post: snippsat
  Is there a *.bat DOS batch script to *.py Python Script converter? pstein 3 3,000 Jun-29-2023, 11:57 AM
Last Post: gologica
  Python script running under windows over nssm.exe JaroslavZ 0 671 May-12-2023, 09:22 AM
Last Post: JaroslavZ
  Running script with subprocess in another directory paul18fr 1 3,468 Jan-20-2023, 02:33 PM
Last Post: paul18fr
  PsInfo from remote computer in python susja 3 2,223 Oct-10-2022, 08:39 AM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

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