diff options
Diffstat (limited to 'xmrstak/cli/cli-miner.cpp')
-rw-r--r-- | xmrstak/cli/cli-miner.cpp | 65 |
1 files changed, 64 insertions, 1 deletions
diff --git a/xmrstak/cli/cli-miner.cpp b/xmrstak/cli/cli-miner.cpp index e152a02..546d226 100644 --- a/xmrstak/cli/cli-miner.cpp +++ b/xmrstak/cli/cli-miner.cpp @@ -66,6 +66,9 @@ void help() cout<<" -v, --version show version number"<<endl; cout<<" -V, --version-long show long version number"<<endl; cout<<" -c, --config FILE common miner configuration file"<<endl; +#ifdef _WIN32 + cout<<" --noUAC disable the UAC dialog"<<endl; +#endif #if (!defined(CONF_NO_AEON)) && (!defined(CONF_NO_MONERO)) cout<<" --currency NAME currency to mine: monero or aeon"<<endl; #endif @@ -82,11 +85,17 @@ void help() cout<<" --nvidia FILE NVIDIA backend miner config file"<<endl; #endif cout<<" "<<endl; - cout<<"The Following options temporary overwrites the config file settings:"<<endl; + cout<<"The Following options temporary overwrites the config entries of \nthe pool with the highest weight:"<<endl; cout<<" -o, --url URL pool url and port, e.g. pool.usxmrpool.com:3333"<<endl; cout<<" -u, --user USERNAME pool user name or wallet address"<<endl; cout<<" -p, --pass PASSWD pool password, in the most cases x or empty \"\""<<endl; cout<<" \n"<<endl; +#ifdef _WIN32 + cout<<"Environment variables:\n"<<endl; + cout<<" XMRSTAK_NOWAIT disable the dialog `Press any key to exit."<<std::endl; + cout<<" for non UAC execution"<<endl; + cout<<" \n"<<endl; +#endif cout<< "Version: " << get_version_str_short() << endl; cout<<"Brought to by fireice_uk and psychocrypt under GPLv3."<<endl; } @@ -263,6 +272,41 @@ void do_guided_config(bool userSetPasswd) std::cout<<"Configuration stored in file '"<<params::inst().configFile<<"'"<<std::endl; } +#ifdef _WIN32 +/** start the miner as administrator + * + * This function based on the stackoverflow post + * - source: https://stackoverflow.com/a/4893508 + * - author: Cody Gray + * - date: Feb 4 '11 + */ +void UACDialog(const std::string& binaryName, std::string& args) +{ + args += " --noUAC"; + SHELLEXECUTEINFO shExInfo = {0}; + shExInfo.cbSize = sizeof(shExInfo); + shExInfo.fMask = SEE_MASK_NOCLOSEPROCESS; + shExInfo.hwnd = 0; + shExInfo.lpVerb = "runas"; + shExInfo.lpFile = binaryName.c_str(); + // disable UAC dialog (else the miner will go into a infinite loop) + shExInfo.lpParameters = args.c_str(); + shExInfo.lpDirectory = 0; + shExInfo.nShow = SW_SHOW; + shExInfo.hInstApp = 0; + + if(ShellExecuteEx(&shExInfo)) + { + printer::inst()->print_msg(L0, + "This window has been opened because xmr-stak needed to run as administrator. It can be safely closed now."); + WaitForSingleObject(shExInfo.hProcess, INFINITE); + CloseHandle(shExInfo.hProcess); + // do not start the miner twice + std::exit(0); + } +} +#endif + int main(int argc, char *argv[]) { #ifndef CONF_NO_TLS @@ -296,6 +340,7 @@ int main(int argc, char *argv[]) } bool userSetPasswd = false; + bool uacDialog = true; for(int i = 1; i < argc; ++i) { std::string opName(argv[i]); @@ -418,6 +463,10 @@ int main(int argc, char *argv[]) } params::inst().configFile = argv[i]; } + else if(opName.compare("--noUAC") == 0) + { + uacDialog = false; + } else { printer::inst()->print_msg(L0, "Parameter unknown '%s'",argv[i]); @@ -426,6 +475,20 @@ int main(int argc, char *argv[]) } } +#ifdef _WIN32 + if(uacDialog) + { + std::string minerArgs; + for(int i = 1; i < argc; i++) + { + minerArgs += " "; + minerArgs += argv[i]; + } + + UACDialog(argv[0], minerArgs); + } +#endif + // check if we need a guided start if(!configEditor::file_exist(params::inst().configFile)) do_guided_config(userSetPasswd); |