Python Forum
Failing to connect to a host with WMI
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Failing to connect to a host with WMI
#5
Well, I was looking for an example for a few days and just found it.
Plugged it in ad it works!
here is the whole snipped if anyone is interested:

import wmi
from socket import *

ip = '101.17.48.11'
username = 'Some_user'
password = 'somepassword'
proc=open('c:\\somedir','w')
try:
    print("Establishing connection to %s" %ip)
    connection = wmi.WMI(ip, user=username, password=password)
    connection = wmi.WMI(ip)
    print("Connection established")

    for process in connection.Win32_Process():
        #print("ID: {0}\nProcessName: {1}\n".format(process.ProcessId,process.Name))
        print(f"Proccess-ID/Nmae -> {process.ProcessId} - {process.Name} ")
        proc.write(str(process.ProcessId)+","+process.Name+"\n")         
except wmi.x_wmi:
    print("Your Username and Password of "+getfqdn(ip)+" are wrong.")
proc.close()
Thank you everyone for the support and coaching!
I think this is the best place to learn Python.
Reply


Messages In This Thread
Failing to connect to a host with WMI - by tester_V - Jul-31-2021, 02:05 AM
RE: Failing to connect to a host with WMI - by tester_V - Aug-03-2021, 10:14 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Failing to connect by 'net use' tester_V 1 1,059 Apr-20-2024, 06:31 AM
Last Post: tester_V
  Failing regex tester_V 3 2,335 Aug-16-2022, 03:53 PM
Last Post: deanhystad
  where to host my python script tomtom 1 1,784 Feb-09-2022, 06:45 AM
Last Post: ndc85430
  Failing to get Stat for a Directory tester_V 11 5,441 Jul-20-2021, 10:59 PM
Last Post: Larz60+
  Failing to Zip files tester_V 4 3,201 Dec-01-2020, 07:28 AM
Last Post: tester_V
  Python 3.8 on mac failing to start sgandon 0 3,749 Jan-14-2020, 10:58 AM
Last Post: sgandon
  trying to install oandapy and failing ErnestTBass 0 2,361 Feb-24-2019, 06:13 PM
Last Post: ErnestTBass
  Pyinstaller failing JP_ROMANO 2 4,949 Jan-16-2019, 06:07 PM
Last Post: JP_ROMANO
  Why is my for loop failing? microphone_head 4 3,954 Sep-11-2018, 01:21 PM
Last Post: microphone_head
  Get host from ip antmar904 3 3,748 Jan-31-2018, 08:27 PM
Last Post: antmar904

Forum Jump:

User Panel Messages

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