WMI version of disk quota (or use C #)

zhaozj2021-02-16  59

Using system.management;

A summary description of Namespace Diskquota {///

/// Class1. /// class class1 {/// /// The primary entry point of the application. /// [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 ()) Console.Writeline ("Next: {0}", O.Path);} catch (Exception E ) {Console.writeline ("Error:" E);

}

}

Description: Use the .NET's management component.

转载请注明原文地址:https://www.9cbs.com/read-21668.html

New Post(0)