wmi

Find application using port

I have a networking program setup that does a lot of what the nestat program does. I am working now on netstat -o. That command will give me the PID of the program using that socket. I have some idea of where to look. I have been trying to use WMI to get that information but so far I have not found a suitable class. How can I find th...

How to eject CD using WMI and Python?

Using Windows' WMI library, how can I eject CD rom mounted in a specific CD/DVD drive? I am asking for sources from WMI docs or examples since I am using wmi.py library on Python. It would be great if solution satisfies Windows computer newer than Windows 2000 and having multi CD-ROMs. (i.e. I have D: F: drives and both are CD-ROM dri...

converting contents of a "string array" AKA SAFEARRAY to wchar

I'm using WMI to read DefaultIPGateway on the WMI object Win32_NetworkAdapterConfiguration. The MSDN says it's a "String Array" and visual studio interprets this as a SAFEARRAY on the VARIANT object returned when you query the WMI. How do you access the information inside the array? How do you convert each element to a wchar* or char*? ...

Programmatically Disable Windows Autoplay

Possible Duplicate: Can I disable window autoplay function programatically with C#/.NET? I am trying to disable Autoplay for all devices in Windows XP programmatically. I know how to do it by running gpedit.msc, then navigating to Computer Configuration -> Administrative Templates -> System -> Turn off Autoplay. I just need a ...

Accessing custom WMI provider hangs indefinitely

Hi all, I'm trying to write a custom decoupled WMI provider in C#. I've followed the examples and yet whenever I try to access my WMI class from either WMI Studio, through PowerShell, or via wmic, it just hangs there indefinitely until I terminate the provider host app, at which point I get an error ranging from "Invalid Class" to "The...

Howto access WMI in SQL CLR Projects

I have a project i've been working on that requires me to retrieve the CPU ID of the computer to create a software licence and check it against the current licens registered. So, said and done i made 2 programs to make this happen. Then i need to implement this solution into my CLR project. I notice that i can't add System.Management ...

How to join in a WMI Query (WQL)

I want to get the serial number of the boot-harddisk via a WQL query. The boot-partition can be retrieved using the following query: SELECT * FROM Win32_DiskPartition where BootPartition=True The serial number is in Win32_DiskDrive: SELECT DeviceID, SerialNumber FROM Win32_DiskDrive Win32_DiskDriveToDiskPartition has the mapping o...

How to pull a range of failed services from a remote server after a reboot

Caveat: Without spiking the cpu while a Get-WmiObject call parses the whole event log to match my specified filter. Situation: I am working on a script that remotely runs some checks, then reboots a pc. I want it to check the health once the server reboots (after sleeping for some time) to make sure services that were supposed to start ...

PowerShell: Format Get-WmiObject output to return only the IP address

I would like to use Get-WmiObject Win32_NetworkAdapterConfiguration to return the ip address of a network card. Unfortunately, I cannot figure out how to format the output to display only the IPv.4 address. Get-WmiObject Win32_NetworkAdapterConfiguration | Select IPAddress | Where-Object {$_.IPaddress -like "192.168*"} Displays: IPA...

WMI error when connecting to IIS7

I am getting the same error described here: http://forums.iis.net/p/1033115/1700749.aspx I have a PowerShell cmdlet that tries to control our web application running on Windows Server 2008 SP2 and IIS 7. One of the first things it tries to do is try to connect to the remote machine using WMI. It does this using code like this: Conne...

Map network drive with a Python service

(There are other questions along these lines but none of them have any real answers, let alone answers dealing with python...) I have a Windows Service (XP SP3) written in Python that needs to be able to mount a network drive for ALL users. I tried using net use with subprocess (even with the full path to net.exe), but given that your ...

What is the WMI call to list Storage disks on a host system?

I Need to fetch disks that are present on the host along with the LUNs/disks(which do have any file sytem on it) that are presented by the SAN to the host. Tried "Win32_volume" but this does not display LUNs/disks, which have unkwown file system on it.Can you please sugggest any WMI class which lists all the disks available on the host s...

How to list subfolders of local area network shares if non-latin characters are in computer name?

I have a php script which lists workgroups/domains, computers in workgroups/domains and shares on computers. The apache is running under specific credentials (so not Local System), so it has access on LAN. Listing subfolders of the shares is working partially: only with latin characters. For example if I have a computer named ABC and a...

WMI Win32_Process WorkingSetSize Vista Issue

On a system monitoring project, I am retrieving process memory usage through WMI. I am using Jacob with Java to do the WMI query: SELECT WorkingSetSize FROM Win32_Process This method retrieves the exact memory usage (comparing to task manager) on Windows XP; however on Windows Vista, the memory usage is about 15% higher than the mem...

"list index out of range"

Below I have the following code that is supposed to get the CPU temperature. import wmi w = wmi.WMI() print w.Win32_TemperatureProbe()[0].CurrentReading When I run it I get the following warning however: Traceback (most recent call last): File "<string>", line 244, in run_nodebug File "<module1>", line 3, in <module> IndexError:...

Using WMI to Determine which adapter(s) is connected to the internet

Hi! I am writing a VB Script that uses WMI to determine which adapter is used for internet connectivity? For example - if I have a LAN and a 3G board it needs to tell the user which is connected. I understand that a machine might have >1 internet connection, but for now, let's assume 1. edit: Ok, how can I do this using any command t...

Getting users of a computer

Hi, I am trying to get the list of local users of a computer using the following code. internal void GetUsers() { try { List<string> adUsers = new List<string>(); DirectoryEntry directoryEntry = new DirectoryEntry("WinNT://" + Environment.MachineName); foreach (Director...

Remote WMI сonnection

I want to connect to remote PC running Windows 7, from another PC using ManagementScope on a local network. On remote PC I've created a new user account "Samuel" without password and set as administrator. ConnectionOptions options = new ConnectionOptions(); options.Username = "Samuel"; options.Password = ""; ManagementScope scope = n...

Killing processes in Vbscript

I am trying to kill all instances of a process called "AetherBS.exe" but the following VBscript is not working. I am not exactly sure where/why this is failing. So how can I kill all process of "AetherBS.exe?" CloseAPP "AetherBS.exe" Function CloseAPP(Appname) strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & st...

obtain the current username using WMI

I am using Win32_NetworkLoginProfile or Win32_Account to get a list of the users for a system. Call to these objects return a lot of users, some local and some belonging to a domain (if the system is part of a domain). Is there a way to obtain the current user name using WMI? If yes, how? furthermore, using Win32_Account I can check wh...