Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Management;
- // This example demonstrates how to connect to remote machine
- // using supplied credentials.
- class Sample_ConnectionOptions {
- static void Main(string[] args) {
- ConnectionOptions options = new ConnectionOptions();
- options.Username = "ABC"; //could be in domain\user format
- options.Password = "DEF";
- ManagementScope scope = new ManagementScope(
- "\\\\servername\\root\\cimv2",
- options);
- try {
- scope.Connect();
- ManagementObject disk = new ManagementObject(
- scope,
- new ManagementPath("Win32_logicaldisk='c:'"),
- null);
- disk.Get();
- } catch (Exception e) {
- Console.WriteLine("Failed to connect: " + e.Message);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement