Hey everyone, I have a quick (and hopefully simple question). I'm writing a simple program that will ask the user for two different inputs(IP address and message), save those as strings, then run a command in command prompt adding those strings on the end as arguments. I'm using it to change the message displayed on HP printer screens by using a little program called HPhack. In command prompt, it would look like this:

HPHack.exe 192.168.10.1 "Message!!"

I'm using system("command") right now, but I don't know how to pass those arguments along with it.


Thanks!

cout<<"Enter IP address of target printer:"<<endl;
    getline (cin, ip);
    
    cout<<"Enter message in quotes:"<<endl;
    getline (cin, message);
    
    system("hphack.exe "ip" "message);
Re: Running Command Prompt and Arguments From C++ 80 80

Hmmm.... I don't know if I should respond to this. Something smells fishy here.

Re: Running Command Prompt and Arguments From C++ 80 80

Don't worry, I'm not using it maliciously. Me and my boss want to use it to mess with someone a little. I can do it without this code, but I'm also learning C++ and really do want to know how to do this, regardless of this specific instance.

I thought about being more general because I knew someone would respond like this, but I thought I'd be open to begin with!

Re: Running Command Prompt and Arguments From C++ 80 80

OK, if you want, you could read how to do it here... Don't misuse it though.

Re: Running Command Prompt and Arguments From C++ 80 80

Thank you! I really won't misuse it. I know this will come in handy sometime in the future though.

Thanks again!

Be a part of the DaniWeb community

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