This progran is a frontend for the windows "taskkill". If i type the output directly into a command window, it works, but it will only kill taskmgr.exe from this app.
Any thoughts appreciated.

#include <iostream>
#include <cstdlib>

using namespace std;
int main(int argc, char *argv[])
{
string computer,domain_user,password,imagename,command,force;
int time;
cout << "What process would you like to kill? ";
cin >> imagename;
cout << "On what computer?(c for current) ";
cin >> computer;
cout << "Enter Domain\\User(c for current) ";
cin >> domain_user;
            if (domain_user == "c")
     {
        domain_user == "c";
     }
   else
     {
        cout << "Password?";
        cin >> password;
     } 
cout << "Force? Y/N";
cin >>force;

command= "taskkill";

///////////////////////////////////////////////////////////////////////////////

   if (computer == "c")
     {
        computer == "c";
     }
   else
     {
        command += " /s "; command +=computer;
     } 
     
///////////////////////////////////////////////////////////////////////////////

        if (domain_user == "c")
     {
        domain_user == "c";
     }
   else
     {
        command += " /u "; command += domain_user;
        command += " /p "; command += password;
     } 
     
///////////////////////////////////////////////////////////////////////////////
command += " /im "; command += imagename ;
///////////////////////////////////////////////////////////////////////////////

        if (force == "F")
     {
        force = "f";
     }
     
   if (force == "f")
     {
        command += " /f ";
     }
   else
     {
        force = "n";
     } 
     
///////////////////////////////////////////////////////////////////////////////
cout << command << "\n";
system(command.c_str());

    system("PAUSE");
    return EXIT_SUCCESS;
}

Recommended Answers

All 2 Replies

Never use system() on Win32
Use Win32 api (TP and others)

Never use system() on Win32
Use Win32 api (TP and others)

What on earth "TP and others" means?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.