Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <windows.h>
- #include "GetProcessID.h"
- #include <iostream>
- #include <string>
- #include <stdio.h>
- #include <tchar.h>
- using namespace std;
- bool checkProcess (LPCTSTR processName);
- int startProcess (LPCTSTR path, LPSTR arugs, LPCTSTR workdir);
- int launchserv(void);
- bool loop = true;
- int main(int argc, char* argv[])
- {
- SetConsoleTitle("ECW Watchdog DO NOT CLOSE!");
- cout << "Welcome to ECW Watchdog Debug Screen! DO NOT CLOSE\n\n";
- while (true) {
- if (!checkProcess("rp2server")) {
- launchserv();
- }
- if (!checkProcess("inspircd")) {
- if (startProcess("C:\\Program Files (x86)\\InspIRCd\\inspircd.exe", NULL, "C:\\Program Files (x86)\\InspIRCd\\")) {
- cout << "Failed to launch IRC Server... \n\n";
- }
- }
- Sleep(5000);
- }
- return 0;
- }
- bool checkProcess (LPCTSTR processName) {
- std::vector<DWORD> SetOfPID;
- GetProcessID(processName,SetOfPID);
- if (SetOfPID.empty()) {
- return false;
- }
- return true;
- }
- int startProcess (LPCTSTR path, LPSTR arugs, LPCTSTR workdir) {
- STARTUPINFO info={sizeof(info)};
- PROCESS_INFORMATION processInfo;
- if(!CreateProcess(path,arugs,NULL, NULL,FALSE, 0,NULL,workdir,&info, &processInfo ) ) {
- return 1;
- } else {
- return 0;
- }
- }
- int launchserv(void) {
- LPCTSTR fpath = "C:\\Users\\Test\\Documents\\Server\\ECWServer\\rp2serv.exe";
- LPCTSTR fdir = "C:\\Users\\Test\\Documents\\Server\\ECWServer";
- cout << "Starting RenFDS \n";
- if (startProcess("C:\\Users\\Test\\Documents\\Server\\ECWServer\\rp2server.exe", NULL, "C:\\Users\\Test\\Documents\\Server\\ECWServer\\")) {
- cout << "Failed to launch RenFDS :( retrying...\n\n";
- Sleep(5000);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement