or
How to connect remote computer through wmi in python
We can connect two computers in network by 2 methods
- Using wmi library
- Using Netuse method
We can use both the method. First we will see, connect two
computers using wmi module.
Connect two network computer using Wmi library
Windows Management Instrumentation (WMI) is a set of
extensions to the Windows Driver Model that provides an operating system
interface through which instrumented components can provide information and
notification. WMI is Microsoft’s implementation of the Web-Based Enterprise Management
(WBEM) Standard from the Distributed Management Task Force(DMTF). WMI allows
scripting languages like VBScript to manage Microsoft Windows personal
computers and servers, both locally and remotely. WMI is preinstalled in
Windows Vista, Windows Server 2003, Windows XP, Windows Me, and Windows 2000.
This tutorial covers accessing WMI specifically using the
Python programming language and assumes you have downloaded and installed
Python itself, the pywin32 extensions and the WMI Python module. The WMI module
assumes that the pywin32 extensions are present, and exposes a slightly more
Python-friendly interface to the sometimes messy WMI scripting API.
Download Wmi library from
here --- DOWNLOAD
Code for local computer Connecting
import wmi c = wmi.WMI()
Code for Network computer Connecting
ip = “192.168.1.13” username = “username” password = “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."
Operating system information
import wmi c = wmi.WMI() for os in c.Win32_OperatingSystem(): print os.Caption
Local or remote Computer Drive information
import wmi c = wmi.WMI() for disk in c.Win32_LogicalDisk(DriveType=3): print disk.Caption
Note:-
if you want to more information or code about operating system through wmi then
follow this site URL
Thanks Guys
Thank you for your posting, but i'm wondering how to install VMI package on MAC (i'm using pycharm to write scripts python)
ReplyDelete