Advertisement
Brandan

Untitled

Dec 2nd, 2013
379
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.68 KB | None | 0 0
  1.  
  2.  
  3. #include "stdafx.h"
  4. #include <windows.h>
  5. #include "GetProcessID.h"
  6. #include <iostream>
  7. #include <string>
  8. #include <stdio.h>
  9. #include <tchar.h>
  10.  
  11. using namespace std;
  12.  
  13. bool checkProcess (LPCTSTR processName);
  14. int startProcess (LPCTSTR path, LPSTR arugs, LPCTSTR workdir);
  15. int launchserv(void);
  16. bool loop = true;
  17.  
  18. int main(int argc, char* argv[])
  19. {
  20.     SetConsoleTitle("ECW Watchdog DO NOT CLOSE!");
  21.  
  22.     cout << "Welcome to ECW Watchdog Debug Screen! DO NOT CLOSE\n\n";
  23.     while (true) {
  24.  
  25.         if (!checkProcess("rp2server")) {
  26.             launchserv();
  27.         }
  28.  
  29.         if (!checkProcess("inspircd")) {
  30.             if (startProcess("C:\\Program Files (x86)\\InspIRCd\\inspircd.exe", NULL, "C:\\Program Files (x86)\\InspIRCd\\")) {
  31.                 cout << "Failed to launch IRC Server... \n\n";
  32.             }
  33.         }
  34.  
  35.         Sleep(5000);
  36.     }
  37.  
  38.     return 0;
  39. }
  40.  
  41. bool checkProcess (LPCTSTR processName) {
  42.     std::vector<DWORD> SetOfPID;
  43.     GetProcessID(processName,SetOfPID);
  44.     if (SetOfPID.empty()) {
  45.         return false;
  46.     }
  47.     return true;
  48. }
  49.  
  50. int startProcess (LPCTSTR path, LPSTR arugs, LPCTSTR workdir) {
  51.     STARTUPINFO info={sizeof(info)};
  52.     PROCESS_INFORMATION processInfo;
  53.  
  54.     if(!CreateProcess(path,arugs,NULL, NULL,FALSE, 0,NULL,workdir,&info, &processInfo ) ) {
  55.         return 1;
  56.     } else {
  57.         return 0;
  58.     }
  59. }
  60.  
  61. int launchserv(void) {
  62.     LPCTSTR fpath = "C:\\Users\\Test\\Documents\\Server\\ECWServer\\rp2serv.exe";
  63.     LPCTSTR fdir = "C:\\Users\\Test\\Documents\\Server\\ECWServer";
  64.  
  65.     cout << "Starting RenFDS \n";
  66.     if (startProcess("C:\\Users\\Test\\Documents\\Server\\ECWServer\\rp2server.exe", NULL, "C:\\Users\\Test\\Documents\\Server\\ECWServer\\")) {
  67.         cout << "Failed to launch RenFDS :( retrying...\n\n";
  68.         Sleep(5000);
  69.     }
  70.  
  71.     return 0;
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement