wmi

how to run a powershell script as a windows service from inside a Java program?

不想你离开。 提交于 2020-01-14 03:50:29
问题 I have the following code that runs a windows service from inside Java.The code uses JInterop Java library, JInterop is a pure Java COM client for windows COM server. More details of JIntop are available here [http://fishi.devtail.io/weblog/2015/01/21/pure-java-dcom-bridge-j-interop/] String cmdFile = "service.bat"; results = wbemServices_dispatch.callMethodA( "Get", new Object[]{ new JIString("Win32_Process"), new Integer(0), JIVariant.OPTIONAL_PARAM()}); IJIDispatch wbemObjectSet_dispatch =

How to read HDD S.M.A.R.T. attributes?

℡╲_俬逩灬. 提交于 2020-01-13 13:50:17
问题 I would monitoring the smart HDD-s on my Windows 7 clients. I would to get the HDD smart attributes without using any vbs file or ready-made tool just looking towards WMI or PowerShell. I would aggregate that data with ZABBIX monitoring server (use zabbix-sender.exe ). I found a more or less solution for Linux, but I would monitor windows 7 machines HDD. Has anyone an idea? 回答1: Use the WMI API to access SMART data like so, gwmi -namespace root\wmi -class MSStorageDriver_FailurePredictStatus

How to restart service remotely?

冷暖自知 提交于 2020-01-12 13:48:34
问题 I can start or stop service remotely from .net project. ConnectionOptions options = new ConnectionOptions(); options.Username = @"192.168.36.22\test"; options.Password = "test"; ManagementScope scope = new ManagementScope(@"\\192.168.36.22\root\cimv2", options); scope.Connect(); ManagementOperationObserver Stop = new ManagementOperationObserver(); Stop.Completed += new CompletedEventHandler(Stop_CallBack); try { string NameServices = "ArcGIS Server"; WqlObjectQuery query = new WqlObjectQuery(

WMI vs Windows APIs

混江龙づ霸主 提交于 2020-01-12 07:35:07
问题 There are any advantages or disadvantages of using the WMI instead of Windows API to access to the information of the system? as speed, additional permissions, memory usage. or depends on the WMI class and how the WMI implements the access to the information? 回答1: The main disadvantage of WMI is speed, it is slow to query data and if you are trying to use it during start up it can delay you starting as the WMI service takes a long time to come up. However, WMI information is richer, as in you

wmi信息

霸气de小男生 提交于 2020-01-10 10:57:27
有时候我们需要知道一些诸如磁盘信息,进程信息一类的东西,有一个现成的类可以使用ManagementClass,他构造函数可以使用Win32_Process和Win32_LogicalDisk,前面一个是进程信息后面一个是磁盘信息。 ManagementClass cls = new ManagementClass("Win32_Process"); ManagementObjectCollection moc = cls.GetInstances(); foreach (ManagementObject obj in moc) { foreach (PropertyData pd in obj.Properties) { // } } Win32_Process属性说明 http://msdn.microsoft.com/zh-cn/library/aa394372%28v=VS.85%29.aspx Win32_LogicalDisk属性说明 http://msdn.microsoft.com/zh-cn/library/aa394173 用Win32_Process可以获得诸如CPU的编号,名称等信息,可以用来指定唯一的机器(比如用在加密代码的时候) 除了上面2个外,还有很多其他的,大家在MSDN里搜索关键字Win32 class就可以看到了

WQL测试工具

天大地大妈咪最大 提交于 2020-01-10 05:11:29
WQL就是WMI中的查询语言,WQL的全称是WMI Query Language,简称为WQL,翻译成中文好像可以成为Windows管理规范查询语言。熟悉SQL语言的朋友会感觉它和SQL非常相似。 WQL其实非常简单,它有如下特点: 1.每个WQL语句必须以SELECT开始; 2.SELECT后跟你需要查询的属性名(我刚才对应SQL将其称之为字段名了),也可以像SQL一样,以*表示返回所有属性值; 3.FROM关键字; 4.你要查询的类的名字; 5.另外,如果你想精确查询结果还可以加上WHERE条件从句。比如某个类有Enable属性,你可以在查询的时候加上WHERE ENABLE=true。 在WinXP和Win2003中有一个自带的WQL测试工具:wbemtest.exe,可以查看有哪些类和类有哪些属性。用法: 1.启动wbemtest.exe,连接时修改默认名称空间root\default为root\cimv2。 2.登陆成功后,从枚举类别...对话框中选中'递归',可以查看系统中有哪些类,和这些类的属性、方法。 如何:列出 WMI 命名空间中的类 http://msdn.microsoft.com/zh-cn/library/ms257362(VS.80).aspx 微软WMI代码生成工具 WMICodeCreatorTools.rar 来源: https://www

How can I change the username/password of an ApplicationPool in IIS from C#?

扶醉桌前 提交于 2020-01-10 04:34:24
问题 I am using the code below to create a new application pool in the Installer class of my application: private static void CreateAppPool(string serverName, string appPoolName) { // metabasePath is of the form "IIS://<servername>/W3SVC/AppPools" // for example "IIS://localhost/W3SVC/AppPools" // appPoolName is of the form "<name>", for example, "MyAppPool" string metabasePath = string.Format("IIS://{0}/W3SVC/AppPools", serverName); Console.WriteLine("\nCreating application pool named {0}/{1}:",

WMI Win32_BaseBoard SerialNumber

ぃ、小莉子 提交于 2020-01-10 03:11:20
问题 I used Win32_BaseBoard SerialNumber property to obtain the motherboard serial number and it work most of the time, but sometimes in some computers I get SerialNumber = "Base Board Serial Number" as a result. Is there a programmatic way to obtain this serial number in a more efficient way or it is simply a manufacturer problem? I have heard that all motherboards come with a serial number with no exception. Is this true? 回答1: Whether the Serial Number returned by various WMI queries will be

初认识WMI

跟風遠走 提交于 2020-01-10 00:20:33
什么是 WMI ? WMI是 Windows Management Instrumentation的缩写,简单来说就是我们可以使用来获得和管理Windows各种信息的接口。更官方的介绍可以查看这篇文章: http://www.microsoft.com/china/M ... pting.mspx?mfr=true 到具体操作时,我们将使用WQL。什么是WQL?从字面上看很熟悉吧,熟悉 数据库 的朋友马上会想到 SQL 。是的,WQL是类似SQL的结构化查询语言,两者的语法也很像,因此熟悉数据库的朋友很快就能理解。不熟悉的朋友也不要担心,因为WQL还是比较容易理解的。下面简单来举一个WQL的例子: 代码: Select * from Win32_Account 其中“select * from ”一般情况下我们可以不去改动,Win32_Account就是WMI的庞大数据库里的一个分支。既然说道庞大,那肯定会有朋友问,我们如何知道所有的分支呢?其实Windows已经自带了一个 工具 供我们查找。在“运行”对话框中输入“c:\windows\system32\wbem\wbemtest.exe”将会启动“windows管理规范测试器”,随后我们单击“连接”,在第一个文本框中输入“root\cimv2”,其它选项保持默认,然后单击连接返回 程序 主界面。我们再单击枚举类别,在“超类别信息

Query WMI from Go

夙愿已清 提交于 2020-01-09 13:06:29
问题 I would like to run WMI queries from Go. There are ways to call DLL functions from Go. My understanding is that there must be some DLL somewhere which, with the correct call, will return some data I can parse and use. I'd prefer to avoid calling into C or C++, especially since I would guess those are wrappers over the Windows API itself. I've examined the output of dumpbin.exe /exports c:\windows\system32\wmi.dll , and the following entry looks promising: WmiQueryAllDataA (forwarded to