I am working on an hotspot maker application for which i am using c++ to execute netsh commands in cmd, but for that i require administrative privileges of cmd.I have used system(runas \user:) but that is giving an unknown error.
My admin user:the_annoying_
PC NAme:Unknown_God
using namespace std;
int main ()
{
string name;
cout << "Enter Name of Wifi Hotspot:" << endl;
cin >> name;
string pass1="0",pass2="1";
while(pass1!=pass2)
{
cout << "Enter the password" << endl;
cin >> pass1;
cout << "Re-enter the password" << endl;
cin >> pass2;
if(pass1!=pass2)
{
cout << "Please enter same passwords" << endl;
}
}
cout << "Working..." << endl;
string command="netsh wlan set hostednetwork mode=allow ssid=" + name + "key=" + pass1;
const char *command1=command.c_str();
cout << "Creating Wifi Hotspot using given Credentials" << endl;
system("runas /user:the_annoying_ command1");
string comm="netsh wlan start hostednetwork";
const char *command2=comm.c_str();
system("runas /user:the_annoying_ command2");
cout << "Hotspot Sucessfully Created" << endl;
}