H
H
hardwellZero2015-05-27 20:42:30
Python
hardwellZero, 2015-05-27 20:42:30

How to run the program on a remote PC?

Good evening Toaster.
How can I run a program (interested in powershell) on a remote PC? There is a username and password, as well as the ip address of the computer.
All this I want to implement in Python.
Connected via wmi:

from socket import *
from multiprocessing import Process, Queue
import optparse
import os
import wmi

parser = optparse.OptionParser()

parser.add_option('-e', '--engine_list',
    action="store", dest="engine_list",
    help="string", default="example")

options, args = parser.parse_args()

list = []
list = options.engine_list.split(',')

def connect(server,queue):
  ip = server
  username = ""
  password = ""
  try:
      print "Establishing connection to %s" %ip
      connection = wmi.WMI(ip, user=username, password=password)
      print "Connection established"
  except wmi.x_wmi:
      print "Your Username and Password of "+getfqdn(ip)+" are wrong."

if __name__ == '__main__':
  
  queue1 = Queue()

  for server in list:
            p1 = Process(target=connect, args=(server,queue1))
            p1.start()

How can I now run something on a remote PC?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
Leo, 2015-05-27
@STLEON

fabric to help you

O
Oxoron, 2015-05-28
@Oxoron

You can use PsExec from Russinovich. About the analogue in Python, something recently slipped on Habré.
You can use PowerShell Remoting, tynts , tunts .
In any case, control does not go through Python, but through ready-made Microsoft mechanisms. Plus, some preparation of the remote computer will be required.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question