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
- {
- public int Main(string[] args)
- {
- ConnectionOptions options = new ConnectionOptions();
- options.Username = UserName; //could be in domain\user format
- options.Password = SecurelyStoredPassword;
- 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);
- }
- return 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement