wmi

Getting the Username from the HKEY_USERS values

Hello, Is there a way to connect between the values under HKEY_USERS to the actual username? I saw some similar questions, but most (if not all) talks about C# code, and my need is in VBScript. ...

VBScript: how to inspect validity of SWbemObjectSet?

I have the following VBScript: SET Wmi = GetObject("winmgmts:\\.\root\cimv2") SET QR = Wmi.ExecQuery("SELECT * FROM Win32_Processor") MsgBox("" & QR.Count) Which works perfectly fine. However, when I query something which doesn't exist: SET Wmi = GetObject("winmgmts:\\.\root\cimv2") SET QR = Wmi.ExecQuery("SELECT * FROM Win32_DoesNot...

WMI to reboot remote machine

I found this code on an old thread to shutdown the local machine: using System.Management; void Shutdown() { ManagementBaseObject mboShutdown = null; ManagementClass mcWin32 = new ManagementClass("Win32_OperatingSystem"); mcWin32.Get(); // You can't shutdown without security privileges mcWin32.Scope.Options.EnableP...

Resolving the WMI DNS Host Name

I am trying to make a comparison between a machine name i have retrieved from AD, and the DNS Host Name i want to get using WMI from the machine. I currently have: foreach (SearchResult oneMachine in allMachinesCollected) { pcName = oneMachine.Properties["name"][0].ToString(); ConnectionOptio...

How to use POWERSHELL to set MimeTypes in an IIS6 website?

I want to be able to replicate this adsutil.vbs behaviour in powershell: cscript adsutil.vbs set W3SVC/$(ProjectWebSiteIdentifier)/MimeMap ".pdf,application/pdf" and I've gotten as far as getting the website object: $website = gwmi -namespace "root\MicrosoftIISv2" -class "IISWebServerSetting" -filter "ServerComment like '%$name%'" i...

Win32_Product InstallLocation (error)

in C#, i'm trying to get some properties from the instances of Win32_Product, but i seem to have an error saying "Object reference not set to an instance of an object." here's the code: class Package { public string productName; public string installDate; public string installLocation; } class InstalledPackages { public static ...

WMI with Qt examples and info

Where can I find more information on and examples of using WMI with Qt? I have no prior experience with WMI. ...

QCroreApplication QApplication with WMI

I found some WMI C++ Application Examples in MSDN website. I have tried the code form the below link http://msdn.microsoft.com/en-us/library/aa390423%28v=VS.85%29.aspx when i copied and run the application as win32 console application it worked well. the same code i ut into the Qt application , When i use QApplication anApplication ...

SQL alert for a stored procedure?

I have a SQL 2005 setup and am rather new :) Been cracking at this for a few hours and I just need some help. I have been able to setup alerts successfully for the standard "SQL server performance events", its fun. So I already have email alerts working. However I need the alert thing to run a stored procedure I have created, and depe...

How to remotely control a Windows Service with ServiceController?

Hi, I'm trying to control Windows Services that are installed in a remote computer. I'm using the ServiceController class. I have this: ServiceController svc = new ServiceController("MyWindowsService", "COMPUTER_NAME"); With this, I can get the status of the Windows Service like this: string status = svc.Status.ToString(); But I...

Is the IIsFtpService WMI class supported for IIS7 compatibility mode?

I heard a rumour that the IIsFtpService WMI class is not supported when using IIS7 (with IIS6 WMI compatability). However, I cannot find this on Microsoft's website. I need to write support for both IIS6 and IIS7. I have tried and failed to use the class with no success, but IIsWebService works just fine. ...

What to monitor on SQL Server

Hi all I have been asked to monitor SQL Server (2005 & 2008) and am wondering what are good metrics to look at? I can access WMI counters but am slightly lost as to how much depth is going to be useful. Currently I have on my list: user connections logins per second latch waits per second total latch wait time dead locks per second ...

Win32_PageFileUsage WMI call returning 0 for CurrentUsage

I am querying for the current page file usage on Windows-based systems. This is meant to run on the .NET Framework, version 2.0 SP1 and has been tested (and works!) on Windows Vista, Windows 7, Windows Server 2003 R2 and Windows Server 2008. On Windows Server 2003 SP2 (original release, not R2) it appears to return 0: using (var query...

PowerShell script to get network card speed of a Windows Computer

What is the PowerShell script to get the speed a specific Windows machine's network card is running at? I know this can be done with a WMI query based statement and will post an answer once I work it out. ...

Check IIS Application pool if its empty (C# / IIS6)

Hi, We're building an installation tool which can install applications by a configuration file. There is a lot of IIS involved and we mostly use WMI for the job. Recently we discovered that 2 of the applications use the same website and application pool. I can check the website to see if it contains any VDirs and delete it (while uninst...

Manipulating Exchange 2003 shared contacts folder remotely

I've got a CRM web app running on a remote server that needs to synchronise it's contacts with the in-house Exchange 2003 shared contacts. Exchange 2003 doesn't appear to support web services. What would the typical approach to this problem be? My initial instinct would be to open port 80 on the Exchange server, run a simple webserver, ...

How can I get the process output error if it executed remotely

Hi all, I started a process remotely using WMI in a C# windows application, how can I get the output error for this process after finishing execution ? thanks ...

What is better for non-active directory stuff, WMI or ADSI?

I've used both technologies in C# for some time now and thus far have not been able to figure out which is better (in terms of ease of use). It seems to me that because there is support for Windows 95 in WMI, it's an older technology than ADSI (which I assume was invented along with Active Directory). However, despite the hint that ADSI ...

C# WMI, Performance Counters, & SNMP Oh My!

I have a C# windows service which listens to a MSMQ and sends each message out as an email. Since there's no UI, I'd like to offer an ability to monitor this service to see things such as # messages in queue, # emails sent (by message type perhaps), # of errors, etc. What is the best/recommended way to accomplish this? Is it WMI or pe...

How do I get the CPU speed and total physical ram in C#?

I need a simple way of checking how much ram and fast the CPU of the host PC is. I tried WMI however the code I'm using private long getCPU() { ManagementClass mObject = new ManagementClass("Win32_Processor"); mObject.Get(); return (long)mObject.Properties["MaxClockSpeed"].Value; } Throws a null reference exception. F...