Advertisement
Guest User

Untitled

a guest
Jul 4th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. using System;
  2. using System.Management;
  3.  
  4. // This example demonstrates how to connect to remote machine
  5. // using supplied credentials.
  6. class Sample_ConnectionOptions {
  7. static void Main(string[] args) {
  8. ConnectionOptions options = new ConnectionOptions();
  9. options.Username = "ABC"; //could be in domain\user format
  10. options.Password = "DEF";
  11. ManagementScope scope = new ManagementScope(
  12. "\\\\servername\\root\\cimv2",
  13. options);
  14. try {
  15. scope.Connect();
  16. ManagementObject disk = new ManagementObject(
  17. scope,
  18. new ManagementPath("Win32_logicaldisk='c:'"),
  19. null);
  20. disk.Get();
  21. } catch (Exception e) {
  22. Console.WriteLine("Failed to connect: " + e.Message);
  23. }
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement