WMI列出磁盘配额
发布日期:2021-06-30 19:11:59 浏览次数:3 分类:技术文章

本文共 969 字,大约阅读时间需要 3 分钟。

using System;
using System.Management;
namespace DiskQuota
{
/// <summary>
/// Class1 的摘要说明。
/// </summary>
class Class1
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main(string[] args)
{
try
{
ManagementClass c = new ManagementClass("Win32_DiskQuota");
ManagementObject quota = c.CreateInstance();
quota["Limit"] = 400000000;
quota["WarningLimit"] = 200000000;
// Get user account object
ManagementObject account = new
ManagementObject("Win32_Account.Domain=TODAY20040216,Name=ASPNET");
account.Get();
// get disk object
ManagementObject disk = new
ManagementObject("Win32_LogicalDisk.DeviceId='F:'");
disk.Get();
quota["QuotaVolume"] = disk;
quota["User"] = account;
quota.Put(); // commit
ManagementClass c = new ManagementClass("Win32_DiskQuota");
Console.WriteLine(c.SystemProperties);
foreach (ManagementObject o in c.GetInstances())
Console.WriteLine("Next : {0}", o.Path);
}
catch(Exception e)
{
Console.WriteLine("error:" + e);
}
}
}
 

转载地址:https://linuxstyle.blog.csdn.net/article/details/1539927 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:C语言中字符数组和字符串指针分析
下一篇:WMI列出Windows中某个目录的用户权限

发表评论

最新留言

留言是一种美德,欢迎回访!
[***.207.175.100]2024年04月20日 14时50分52秒

关于作者

    喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!

推荐文章