Answer the question
In order to leave comments, you need to log in
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()
Answer the question
In order to leave comments, you need to log in
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 questionAsk a Question
731 491 924 answers to any question