Good Day all,
It's me again.. Yet again I am stumped as always. I am trying to create a remote process killer which in my infrastructure I gotta clean out some processes from some computers "out side the box". I thought if I can make a cool C++ program that accepts the ip or hostname, domain, userid and the process then proceeds to add the inputs into a system command I use very often to eliminate a suspicious process. I always seem to bump into an issue at the end. Remember I am a beginner so sorry for my bad syntax. I would really appreciate the assistance.
Code:
#include <cstdlib>
#include <iostream>
#include <windows.h>
using namespace std;
char pcname[256];
char domain[256];
char userid[256];
char process[256];
int main()
{
cout << "Remote Process Kill Utility \n";
cout << "Please Provide target hostname \n ->";
cin >> pcname;
cout << "\nDomain \n ->";
cin >> domain;
cout << "\nUser id \n ->";
cin >> userid;
cout << "\nProcess name *Example explorer.exe \n ->";
cin >> process;
system("cls");
system("Loading..");
system("taskkill /s " + pcname + " /u " + domain + "\\" + userid + " /fi " "username ne nt*" "/im " + process + "");
return 0;
}
Update..
Oh man... So close... Can someone help me add quotes to a system command string. It like totally ignores the quotes.
Code:
#include <cstdlib>
#include <iostream>
#include <windows.h>
using namespace std;
static string pcname;
static string domain;
static string userid;
static string process;
int main()
{
cout << "Remote Process Kill Utility \n";
cout << "------------------------------\n";
cout << "Please Provide target hostname \n ->";
cin >> pcname;
cout << "\nDomain \n ->";
cin >> domain;
cout << "\nUser id \n ->";
cin >> userid;
cout << "\nProcess name *Example explorer.exe \n ->";
cin >> process;
system("cls");
system("echo Loading..");
system(("echo taskkill /s " + pcname + " /u " + domain + "\\" + userid + " /fi " + """username ne nt*""" + " /im " + process + "").c_str());
system("pause");
return 0;
}
output:
Taskkill /s pcname /u domain\userid /fi "username ne nt*" /IM process
I can't add the quotes between username and nt!! sooo close yet so far!!!