假定有一个应用程序定期通过 WMI Root\Microsoft\Windows\TaskScheduler\MSFT_ScheduledTask 为该查询计划的任务。每次运行 WMI 查询时,WMI 提供程序进程内存使用量增加。最终,内存使用率达到 WMI 提供程序进程配额,并没有更多的 WMI 查询可以进行此过程。
原因:
WMI 查询来监视计划的任务运行时,内存泄漏在 Wmiprvseexe 过程中由于出现此问题。
可以通过使用以下方法之一来获取此更新或修补程序。我们发布了通过 Windows Update 更新和 Microsoft 更新目录为 Windows Server 2012 R2。我们还发布了一个修补程序的 Windows Server 2012。即使此问题仅在 Windows Server 2012 R2 或 Windows Server 2012 中观察到,此更新还将应用于 Windows 81 和 Windows RT 81。
方法 1: Windows 更新
提供此更新为 Windows Update 上推荐更新。有关如何运行 Windows 更新的详细信息,请参阅如何通过 Windows 更新获取更新
方法 2: Microsoft 更新目录
要获得此更新的独立安装包,请转到Microsoft 更新目录网站。
最后,
您可能需要您在应用此更新或修补程序后,重新启动计算机,即可。
以下源码来着网络,本人不拥有该源码的任何权利;且不愿承担刊登该源码的任何责任;如果我的行为侵犯了你的利益,请给我通知,我会第一时间维护你的权益;
c# 获取系统基本信息
//cpu的编号
using SystemManagement;
ManagementClass mc = new ManagementClass("Win32_Processor");
ManagementObjectCollection moc = mcGetInstances();
String strCpuID = null;
foreach (ManagementObject mo in moc)
{
strCpuID = moProperties["ProcessorId"]ValueToString();
thislabel1Text = strCpuID;
break;
}
//获取CPU基本信息
using SystemRuntimeInteropServices;
[DllImport("kernel32 ")]
public static extern void GetSystemInfo(ref CPU_INFO cpuinfo);
//定义CPU的信息结构
[StructLayout(LayoutKindSequential)]
public struct CPU_INFO
{
public uint dwOemId;
public uint dwPageSize;
public uint lpMinimumApplicationAddress;
public uint lpMaximumApplicationAddress;
public uint dwActiveProcessorMask;
public uint dwNumberOfProcessors;
public uint dwProcessorType;
public uint dwAllocationGranularity;
public uint dwProcessorLevel;
public uint dwProcessorRevision;
}
private void Form1_Load(object sender, EventArgs e)
{
//调用GetSystemInfo函数获取CPU的相关信息
CPU_INFO CpuInfo;
CpuInfo = new CPU_INFO();
GetSystemInfo(ref CpuInfo);
string a = "本计算机中有 " + CpuInfodwNumberOfProcessorsToString()+ "个CPU ";
string b = "CPU的类型为 " + CpuInfodwProcessorTypeToString();
string c = "CPU等级为 " + CpuInfodwProcessorLevelToString();
string d = "CPU的OEM ID为 " + CpuInfodwOemIdToString();
string e = "CPU中的页面大小为 " + CpuInfodwPageSizeToString();
}
//获取物理内存
using SystemManagement;//注意需要引用
string st = "";
ManagementClass mc = new ManagementClass("Win32_ComputerSystem");
ManagementObjectCollection moc = mcGetInstances();
foreach (ManagementObject mo in moc)
{
st = mo["TotalPhysicalMemory"]ToString();
}
//显示卡信息
ManagementObjectSearcher searcher = new ManagementObjectSearcher(@"root\CIMV2", "SELECT FROM Win32_VideoController");
foreach (ManagementObject info in searcherGet())
{
string a = "适配器兼容性 "+ info["AdapterCompatibility"]ToString();
string b = "适配器类型 "+ info["AdapterDACType"]ToString();
string c = "视频模式描述"+info["VideoModeDescription"]ToString();
string d = "字幕"+info["Caption"]ToString();
string e = "目前比特每像素"+info["CurrentBitsPerPixel"]ToString();
string f = "目前的水平分辨率"+info["CurrentHorizontalResolution"]ToString();
string g = "视频处理器"+info["VideoProcessor"]ToString();
string h = "最大刷新率" + info["MaxRefreshRate"]ToString();
string i = "设备ID" + info["DeviceID"]ToString();
string j = "描述" + info["Description"]ToString();
}
//获取分区信息
using SystemManagement;
private void button1_Click(object sender, EventArgs e)
{
WqlObjectQuery wmiquery = new WqlObjectQuery("SELECT FROM Win32_LogicalDisk WHERE DeviceID = 'e:'");
ManagementObjectSearcher wmifind = new ManagementObjectSearcher(wmiquery);
foreach (ManagementObject mobj in wmifindGet())
{
string a = ("磁盘类型: " + mobj["Description"]ToString());
string b = ("分区类型: " + mobj["FileSystem"]ToString());
string c = ("可用空间: " + mobj["FreeSpace"]ToString());
string d = ("实际大小: " + mobj["Size"]ToString());
}
}
//获取主板信息
using SystemManagement;
ManagementObjectSearcher my = new ManagementObjectSearcher("SELECT FROM Win32_BaseBoard");
foreach (ManagementObject share in myGet())
{
string a = "主板制造商:" + share["Manufacturer"]ToString();
string b = "产品:" + share["Product"]ToString();
string c = "主板序列号:" + share["SerialNumber"]ToString();
}
//获取IP地址
using SystemManagement;
string st = "";
ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
ManagementObjectCollection moc = mcGetInstances();
foreach (ManagementObject mo in moc)
{
if ((bool)mo["IPEnabled"] == true)
{
//st=mo["IpAddress"]ToString();
SystemArray ar;
ar = (SystemArray)(moProperties["IpAddress"]Value);
st = arGetValue(0)ToString();
String ipadd = st;
break;
}
}
//获取进程详细信息
using SystemDiagnostics;
string s = "";
SystemInt32 processid;
Process process;
//Retrieve the additional information about a specific process
processid = Int32Parse(thistextBox1Text);
process = SystemDiagnosticsProcessGetProcessById(processid);
s = s + "该进程的总体优先级类别:" + ConvertToString(processPriorityClass) + " \r\n";
s = s + "由该进程打开的句柄数:" + processHandleCount + "\r\n";
s = s + "该进程的主窗口标题:" + processMainWindowTitle + "\r\n";
s = s + " 该进程允许的最小工作集大小:" + processMinWorkingSetToString() + " \r\n";
s = s + "该进程允许的最大工作集大小:" + processMaxWorkingSetToString() + " \r\n";
s = s + "该进程的分页内存大小:" + processPagedMemorySize + "\r\n";
s = s + "该进程的峰值分页内存大小:" + processPeakPagedMemorySize + "\r\n";
SystemWindowsFormsMessageBoxShow(s);
为了避免异常崩溃 建议放在 TRY 里运行
//获取系统的启动日期和安装日期
SystemManagementObjectQuery MyQuery=new ObjectQuery("SELECT FROM Win32_OperatingSystem");
SystemManagementManagementScope MyScope=new ManagementScope();
ManagementObjectSearcher MySearch=new ManagementObjectSearcher(MyScope,MyQuery);
ManagementObjectCollection MyCollection=MySearchGet();
string StrInfo="";
foreach(ManagementObject MyObject in MyCollection)
{
StrInfo=MyObjectGetText(TextFormatMof);
}
string InstallDate=StrInfoSubstring(StrInfoLastIndexOf("InstallDate")+15,14);
string LastBootUpTime=StrInfoSubstring(StrInfoLastIndexOf("LastBootUpTime")+18,14);
string a =InstallDate;
string b =LastBootUpTime;
你好:
你可以使用dir()获取wmi的函数信息;
import wmiimport os
import sys
import platform
import time
def sys_version():
c = wmiWMI ()
#获取 *** 作系统版本
for sys in cWin32_OperatingSystem():
print "Version:%s" % sysCaptionencode("UTF8"),"Vernum:%s" % sysBuildNumber
print sysOSArchitectureencode("UTF8")#系统是32位还是64位的
print sysNumberOfProcesses #当前系统运行的进程总数
def cpu_mem():
c = wmiWMI ()
#CPU类型和内存
for processor in cWin32_Processor():
#print "Processor ID: %s" % processorDeviceID
print "Process Name: %s" % processorNamestrip()
for Memory in cWin32_PhysicalMemory():
print "Memory Capacity: %fMB" %(int(MemoryCapacity)/1048576)
def cpu_use():
#5s取一次CPU的使用率
c = wmiWMI()
while True:
for cpu in cWin32_Processor():
timestamp = timestrftime('%a, %d %b %Y %H:%M:%S', timelocaltime())
print '%s | Utilization: %s: %d %%' % (timestamp, cpuDeviceID, cpuLoadPercentage)
timesleep(5)
def disk():
c = wmiWMI ()
#获取硬盘分区
for physical_disk in cWin32_DiskDrive ():
for partition in physical_diskassociators ("Win32_DiskDriveToDiskPartition"):
for logical_disk in partitionassociators ("Win32_LogicalDiskToPartition"):
print physical_diskCaptionencode("UTF8"), partitionCaptionencode("UTF8"), logical_diskCaption
#获取硬盘使用百分情况
for disk in cWin32_LogicalDisk (DriveType=3):
print diskCaption, "%02f%% free" % (1000 long (diskFreeSpace) / long (diskSize))
def network():
c = wmiWMI ()
#获取MAC和IP地址
for interface in cWin32_NetworkAdapterConfiguration (IPEnabled=1):
print "MAC: %s" % interfaceMACAddress
for ip_address in interfaceIPAddress:
print "ip_add: %s" % ip_address
#获取自启动程序的位置
for s in cWin32_StartupCommand ():
print "[%s] %s <%s>" % (sLocationencode("UTF8"), sCaptionencode("UTF8"), sCommandencode("UTF8"))
#获取当前运行的进程
for process in cWin32_Process ():
print processProcessId, processName
def main():
sys_version()
#cpu_mem()
#disk()
#network()
#cpu_use()
if __name__ == '__main__':
main()
print platformsystem()
print platformrelease()
print platformversion()
print platformplatform()
print platformmachine()
Set wmiService = GetObject("winmgmts:\\\root\cimv2")
Set wmiObjects = wmiServiceExecQuery("SELECT FROM CIM_OperatingSystem")
For Each wmiObject In wmiObjects
all=wmiObjectTotalVisibleMemorySize
over=wmiObjectFreePhysicalMemory
next
use=all-over
msgbox use/1024&"MB内存使用中"
'Created By escortmnm from VBS团队
以上就是关于用WMI查询信息,后 不显示结果全部的内容,包括:用WMI查询信息,后 不显示结果、怎么取得硬盘和内存的类型和厂商 C#语言编写,写重点代码。简洁要简洁,谢谢、python获取windows信息等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)