Guest User

Untitled

a guest
Mar 30th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. string sLogin = "Administrator";
  2. string sPassword = "Bzpa/123456789";
  3. string sComputer = "192.168.201.224";
  4.  
  5. //создание процесса на удаленной машине
  6. ManagementScope ms;
  7. ConnectionOptions co = new ConnectionOptions();
  8. co.Username = sLogin;
  9. co.Password = sPassword;
  10. co.EnablePrivileges = true;
  11. co.Impersonation = ImpersonationLevel.Impersonate;
  12.  
  13. ms = new ManagementScope(string.Format(@"\{0}rootCIMV2", sComputer), co);
  14.  
  15. ms.Connect();
  16.  
  17. ManagementPath path = new ManagementPath("Win32_Process");
  18. System.Management.ManagementClass classObj = new System.Management.ManagementClass(ms, path, null);
  19. System.Management.ManagementBaseObject inParams = null;
  20. inParams = classObj.GetMethodParameters("Create");
  21. inParams["CommandLine"] = "notepad.exe";
  22. inParams["CurrentDirectory"] = "C:\WINDOWS\system32\";
  23. ManagementBaseObject outParams = classObj.InvokeMethod("Create", inParams, null);
  24.  
  25. var serverName = "192.168.201.224";
  26. try
  27. {
  28. //Start the process
  29. ProcessStartInfo info = new ProcessStartInfo("C:\PsTools");
  30. info.FileName = @"C:PsToolspsexec.exe";
  31. info.Arguments = @"\" + serverName + @" -i C:WINDOWSnotepad.exe";
  32. info.RedirectStandardOutput = true;
  33. info.UseShellExecute = false;
  34. Process p = Process.Start(info);
  35. }
  36. catch (Exception ex)
  37. {
  38. MessageBox.Show(ex.Message);
  39. }
Add Comment
Please, Sign In to add comment