// Win32_logicaldisk
// Import dll: solution ==> reference ==> add reference ==> com ==> system. Management. dll -- c: \ windows \ Microsoft. NET \ framework \ v1.1.4322
Using System;
Using System. Management;
Class Disk // Data management objects
{
Public Static Void Main ()
{
// Create a C: instance
Managementobject Disk = New Managementobject ( " Win32_logicaldisk.deviceid = \ " C :\ "" );
Disk. Get ();
Console. writeline ( " Disk size " + Disk [ " Size " ] + " Bytes " ); // Print C: size, in bytes
}
}
Determine whether the computer name or IP address is a physical computer or virtual IP address cimv2: win32_computersystem
Run the process cimv2: win32_process on a remote computer
Check whether a directory cimv2: win32_directory exists in the remote computer.
Stop/Start IIS system. Diagnostics. Process
SetProgramSet added to Global Assembly Cache (GAC) system. Diagnostics. Process
Register and configure the GAM component comadmin directory (COM1.0)
Create a web site system. directoryservices. directoryentry
// You can use this method to select some records in the Set "select * From win32_service where name = 'servicename '",
" Win32_logicaldisk " Class // Through this we can view the local drive
Managementobjectsearcher Query = New Managementobjectsearcher ( " Select * From win32_logicaldisk " ); // Query
Managementobjectcollection querycollection = Query. Get (); // Get gets the set and assigns it to collention
Foreach (Managementobject Mo In Querycollection) // Partial calendar set
{
Console. writeline ( " Type: " + Mo [ " Drivetype " ]. Tostring ());
Sconsole. writeline ( " Drive: " + Mo [ " Name " ]. Tostring ()); // Print out All Drives
}
" Win32_environment " Class // Environment Variable
Using System;
Using System. Management;
Public Class Enumerateinstances
{
Public Static Void Main ()
{
Selectquery Query = New Selectquery ( " Win32_environment " );
Managementobjectsearcher searcher = New Managementobjectsearcher (query );
Foreach (Managementbaseobject envvar In Searcher. Get ())
Console. writeline ( " Variable: {0}, value = {1} " , Envvar [ " Name " ], Envvar [ " Variablevalue " ]);
}
}
" Win32_operatingsystem " Class // Operating System Information
Console. writeline ( " Operating System: " + Mo [ " Caption " ]);
Console. writeline ( " Version: " + Mo [ " Version " ]);
Console. writeline ( " Manufacturer: " + Mo [ " Manufacturer " ]);
Console. writeline ( " Computer Name: " + Mo [ " Csname " ]);
Console. writeline ( " Windows directory: " + Mo [ " Windows Directory " ]);
"Win32_service"Class//System Service
// Output the directory structure of the default site
Using System;
Using System. directoryservices;
Class Iisfolderlist
{
Static Void Listfolder (directoryentry paraentry, Int Paraindent)
{
For ( Int I = Paraindent; I > 0 ; I -- )
Console. Write ( ' ' );
Console. writeline (paraentry. Name );
Paraindent ++ ;
Foreach (Directoryentry tempentry In Paraentry. Children)
Listfolder (tempentry, paraindent );
Paraentry. Dispose ();
}
Static Void Main ( String [] ARGs)
{
Listfolder ( New Directoryentry ( " IIS: // localhost/w3svc/1/root " ), 0 );
}
}