Disk quota WMI version (C #)

xiaoxiao2021-03-06  77

Using system;

Using system.management;

Namespace Diskquota

{

///

/// Class1 summary description.

///

Class class1

{

///

/// The main entry point for 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);

ManagementObject O IN C.GetInstances ())

Console.WriteLine ("Next: {0}", O.Path);

}

Catch (Exception E)

{

Console.writeline ("Error:" E);

}

}

}

}

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

New Post(0)