wmi

Addressing "Access Denied" Exception with WMI Calls

I'm getting an exception with a message of "Access Denied" when executing against a WMI request. Some WMI requests appear to require higher security privileges than others. Ultimately my goal is to monitor process launches within the system and log. Regardless if there is a better approach, its now become a vendetta in getting this WM...

How to run a command on a remote Windows system as a non-admin user with WMI?

I have a script written in Visual Basic that starts a process (given to the script as an argument) on a remote system (again, given as an argument) using WMI. This script works fine when using an Administrator account on the remote system, but when using a non-administrator account, I get the following error: ConnectServer Failed w/ (-2...

Obtaining Nearby Wifi In C

I am trying to identify a method for obtaining nearby wifi access points using C in Windows. I am coding in Visual Studio 2010. I have read the necessary documentation but am lacking in guidance on how to implement code that would accomplish this. I am specifically interested in obtaining the MAC address of nearby access points or at a ...

Getting USB Storage Device Instance ID (unique ID) programmatically

Whenever user plug a USB mass storage device, how to get the Device Instance ID (unique ID) of that particular device programmatically? ...

C# WMI Remote Process Create -GUI Hack

I've written a C# Windows Service that restarts processes and services on remote machines. It works fine, however for some of the processes that I need to restart, The application needs a GUI.... .....Are there any hacks to get the GUI to display when starting a process remotely? ...

c# Active Directory via WMI

Hi! Does anyone has some example about accessing Active Directory, LDAP querying using WMI (System.Management namespace) and not System.DirectoryServices namespace. Here on MSDN page it is described a little using CIM classes http://msdn.microsoft.com/en-us/library/aa392320(v=VS.85).aspx But I cant find some C# example realizing it. ...

When querying the Win32_NTLogEvent Class from WMI with WQL is the TimeGenerated property based on Local time of the computer or GMT?

I am writing a C# windows service that is doing some churning through the eventlog on a few domain controllers. Some of them are Windows Server 2003 and some are Windows Server 2008. Upon the service stopping I am attempting to resume where I left off in the logs. In order to do this instead of SELECT * FROM Win32_NTLogEvent WHERE --cr...

Registering Windows Programs to Installed Programs List

As you know, Windows has a "Add/Remove Programs" system in the Control Panel. Let's say I am preparing an installer and I want to register my program to list of installed programs and want it to be uninstallable from "Add/Remove Programs"? Which protocols should I use. Any tutorials or docs about registering programs to that list? I ...

WMI Access denied issue

I am using C# & WMI to retrieve REMOTE COMPUTER services. The connection is made using ConnectionOptions with username & password. Username has administrative privilege. I can query Win32_OperatingSystem OR Win32_LogicalDisk without any problem. But when I query SELECT * FROM Win32_Service then I get Access Denied issue. I give permissio...

wmi performance for following queries

I'm using following two WMI queries : SELECT * FROM Win32_Group WHERE LocalAccount=true SELECT Domain,Name FROM Win32_UserAccount WHERE LocalAccount=true The 2nd query takes about 6 seconds to run (over only 4 users) whereas the 1st query takes about .3 seconds to run over 22 groups. Can somebody tell me why is there such a performan...

Why can't I get Win32_UninterruptiblePowerSupply to work?

I have some simple code: ManagementObjectSearcher searcher = new ManagementObjectSearcher("select * from Win32_UninterruptiblePowerSupply"); ManagementObjectCollection items = searcher.Get(); foreach (ManagementObject item in items) { // Some code here... } The "items" object is semi-null. It's actually an object, but a cal...

Programming in a batch script

Hey all I have a simple problem I was hoping someone can give me assistance with. I'm trying to get WMIC to return output however on different machines, the executable is in different directories. Is there a method to check all directories I list to get it to run, e.g.: IF EXIST wmic=c:\checkhere\ ELSE wmic=c:\checkthisone\ CONTINUE ...

How do you remove/delete a mount point in windows

Im looking for a way to remove a mount point (with either powershell/wmi/C#). I used the win32_volume to find what volumes have mount points and can find the path there (under name and caption) but i cant figure out how to delete those mount points. the win32_volume namespace has a method to create them but nothing to delete. the win32_m...

WMI VBScript vs C#

Hey all, I'm trying to get info about installed software on local computers (one is Windows 7 and other XP SP3) and I'm able to do it with VBScript, but not with C#. Here is the VBScript code: strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" _ & strComputer & "\root\cimv2"...

How to manage users with interactive logon rights?

Can anyone tell me how I can manage(or if not possible, monitor) programatically the people who are allowed to interactively logon(that is through actual physical access) on a windows machine attached to an active directory architecture? Something in BCL/FCL is preferred but COM interop/WMI is also fine. ...

WMI GetPropertyQualifierValue "Not found"

My question is really simple, but apparently nobody's experienced a similar error. I'm writing a program to check if a WMI Class's property is writeable, that is, if the "Write" qualifier is true for that property. My code looks like this: ManagementObjectSearcher mos = new ManagementObjectSearcher("root\\\CIMV2", "SELECT * FROM " + "W...

Performance Counter Input string was not in a correct format C#

Here is my code float cpuLoad = 0; try{ MessageBox.Show("Running"); //CPU Load PerformanceCounter cpuCounter = new PerformanceCounter(); cpuCounter.CategoryName = "Processor"; cpuCounter.CounterName = "% Processor Time"; cpuCounter.InstanceName = "_Total"; MessageBox.Show("Performance Counter Created"); ...

netstat command on a server (winform application)

Hello, I'm looking for how to recorgnize some server (windows in my case) network configuration (information we obtain using netstat dos command). I have the login and password of the target (server), and I developp with visual studio 2005 (c# or vB.NET doesn't matter). (Can I use WMI for that ???) Regards, ...

How can I retrieve a Windows Computer's SID using WMI?

I'm not looking for User SIDs. I'm looking for the computer SID, which active directory would use to uniquely identify the computer. I also don't want to query the active directory server, i want to query the computer itself. ...

WMI to change logging levels in WCF?

I see a bunch of articles on MSDN on how WMI can do all kinds of things, and even a mention of how I can use AppDomainInfo to change the logging and tracing levels at runtime using WMI, but no code examples or implementations anywhere. Has anyone done this? I'm using .net 4.0.. ...