Guest User

Untitled

a guest
Jun 19th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. public void startProcessorDotNetService(){
  2. String currentServerHostname = "<remote_machine_ip>";
  3. String currentServerUser = "<user_name>";
  4. String currentServerPass="dyAf&E47p?s";
  5. String commandToStart="start serviceName";
  6. String commandToStop="stop serviceName";
  7. String psCommand ="<path_to_PSTools_directory>\psservice \\"+ currentServerHostname + " -u " + currentServerUser + " -p " + currentServerPass;
  8. psCommandStart = psCommand + " " + commandToStart;
  9. psCommandStop = psCommand + " " + commandToStop;
  10. serviceStart();
  11. // serviceStop();
  12. }
  13.  
  14. private void serviceStart() {
  15. String[] command = {
  16. "cmd",
  17. };
  18.  
  19. Process p;
  20.  
  21. try{
  22. p=Runtime.getRuntime().exec(command);
  23. PrintWriter stdin = new PrintWriter(p.getOutputStream());
  24. stdin.println(psCommandStart);
  25.  
  26. stdin.close();
  27. p.waitFor();
  28.  
  29.  
  30. }catch (Exception e){
  31. e.printStackTrace();
  32. }
  33. }
  34.  
  35. The user name or password is incorrect.
  36. 'E47p?s' is not recognized as an internal or external command,
  37. operable program or batch file.
Add Comment
Please, Sign In to add comment