Yanir Goren was kind enough to share the following QTip, which allows you to completely disable a network adapter: Dim i Dim adptCount , objDrvs ,sMACAddress i = 0 sMACAddress = “Enter MAC Address Here” ‘The adapter’s Mac Address ‘**** create instance of network adapters*** set objDrvs = GetObject(“winmgmts:”).InstancesOf(“Win32_NetworkAdapter”) adptCount = objDrvs.count ‘**** object contain [...]
Posts in category WMI
Disabling a Network Adapter
Get all Processing on the Local Machine
Get all running processing on the local machine: Dim objWMIService, objProcess, colProcess Dim strComputer, strList strComputer = “.” Set objWMIService = GetObject(“winmgmts:” _ & “{impersonationLevel=impersonate}!\\” _ & strComputer & “\root\cimv2″) Set colProcess = objWMIService.ExecQuery _ (“Select * from Win32_Process”) For Each objProcess in colProcess strList = strList & vbCrLf & _ objProcess.Name Next Print strList
Determine the Name of the Time Zone in which a Computer is Running
Use the Win32_TimeZone class and check the value of the Description property. Set wmiService = GetObject( “Winmgmts:root\cimv2″ ) Set items = wmiService.ExecQuery( “Select * from Win32_TimeZone” ) For Each item in items Print “Description: ” & item.Description Print “Daylight Name: ” & item.DaylightName Print “Standard Name: ” & item.StandardName Next
Convert WMI Dates to Standard Dates and Times
To convert WMI dates to FILETIME or VT_DATE format or to parse the date into component year, month, day, hours, and so on, you must write your own code. Set dtmInstallDate = CreateObject( “WbemScripting.SWbemDateTime” ) Set wmiService = GetObject( “Winmgmts:root\cimv2″ ) Set os = wmiService.ExecQuery( “Select * from Win32_OperatingSystem” ) For Each itemOS in os [...]
Create and Save a Word Document
Demonstration script that retrieves network adapter data from a computer, displays that data in a Microsoft Word document, and then saves the document as C:\Word\Network Adapter Report.doc. Set word = CreateObject( “Word.Application” ) word.Caption = “Test Caption” word.Visible = True Set doc = word.Documents.Add() Set selection = word.Selection With selection .Font.Name = “Arial” .Font.Size = [...]
Determine if a Folder Has Any Files with a Specific File Extension
All we have to do is write a WMI query that includes the path of the folder we want to check as well as the file extension we’re checking for. For example, this script retrieves a collection of all the .bak files found in the C:\Logs folder: Option Explicit Dim wmiService, files Set wmiService = [...]
Get a List of all DLL Files in a Folder
Option Explicit Dim wmiService, fileList, file Dim dirName, machine dirName = “C:\Windows\System32″ machine = “.” Set wmiService = GetObject( “winmgmts:\\” & machine & “\root\cimv2″) Set fileList = wmiService.ExecQuery ( “ASSOCIATORS OF {Win32_Directory.Name=’” & dirName & “‘} Where ResultClass = CIM_DataFile” ) For Each file In fileList If file.Extension = “dll” Then Print file.FileName & “.dll; [...]




Recent Comments