Member Avatar for vs49688

Hi. I am trying to make a program that will launch restricted user-specified programs at my school. How would I make the system() function below make use of the two variables in it.
I've tried && and ||, but the bugger wont work.

#define runasc "runas /profile /user:tsc\\staffuser"

system( runasc programc );

programc is whatever the user enters earlier in the program.

Thanks in advance.

Recommended Answers

All 2 Replies

std::string runasc "runas /profile /user:tsc\\staffuser" ;
system( ( runasc + " " + programc ).c_str() ) ;

I'm not sure if this is what you mean but:

#include <iostream>
[....]
std::string programc = "something";
std::string total = "";

total += runasc;
total += programc ; 
system(total.c_str());
[...]

[edit] Too slow [/edit]

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.