diff options
author | psychocrypt <psychocrypt@users.noreply.github.com> | 2017-11-30 22:46:00 +0100 |
---|---|---|
committer | psychocrypt <psychocrypt@users.noreply.github.com> | 2017-12-06 22:21:48 +0100 |
commit | 7ca6f6e2e9bd5f7a68c878a60a296af1a3636c6f (patch) | |
tree | 3e6762e99bbedd8f6cb0a3d7a919af27451038ca /xmrstak | |
parent | 47a4d031bcc3159a298afaae6797cd19240ad0a1 (diff) | |
download | xmr-stak-7ca6f6e2e9bd5f7a68c878a60a296af1a3636c6f.zip xmr-stak-7ca6f6e2e9bd5f7a68c878a60a296af1a3636c6f.tar.gz |
allow to diable UAC dialog
- remove CMake option `WIN_UAC`
- spawn UAC dialog via restarting xmr-miner with administrator right
- allow to disable UAC with `--noUAC`
- update documentation
- remove usage section with help message (output depends on OS)
Diffstat (limited to 'xmrstak')
-rw-r--r-- | xmrstak/cli/cli-miner.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/xmrstak/cli/cli-miner.cpp b/xmrstak/cli/cli-miner.cpp index e32733b..087d3b6 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 @@ -269,6 +272,38 @@ 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(std::string binaryName) +{ + 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 = "--noUAC"; + shExInfo.lpDirectory = 0; + shExInfo.nShow = SW_SHOW; + shExInfo.hInstApp = 0; + + if(ShellExecuteEx(&shExInfo)) + { + 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 @@ -302,6 +337,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]); @@ -424,6 +460,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]); @@ -432,6 +472,11 @@ int main(int argc, char *argv[]) } } +#ifdef _WIN32 + if(uacDialog) + UACDialog(argv[0]); +#endif + // check if we need a guided start if(!configEditor::file_exist(params::inst().configFile)) do_guided_config(userSetPasswd); |