From f8b68fc82371843ad3f6a0fb0242432e13ec3d20 Mon Sep 17 00:00:00 2001 From: Nicholas O'Connor Date: Sat, 2 Jan 2016 11:14:02 -0800 Subject: [PATCH] if the JSON has an asadmin field set to true, run the link as admin --- Tilandis/linkmgmt.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Tilandis/linkmgmt.cpp b/Tilandis/linkmgmt.cpp index ead94e1..1ed3f23 100644 --- a/Tilandis/linkmgmt.cpp +++ b/Tilandis/linkmgmt.cpp @@ -129,8 +129,15 @@ bool Tilandis::Links::LaunchLink(const wchar_t * LinkName) { std::wstring args; if (link.HasMember(L"args")) { args = link[L"args"].GetString(); } else { args = L""; } + bool asadmin = false; + if (link.HasMember(L"asadmin")) { asadmin = link[L"asadmin"].GetBool(); } - ShellExecute(NULL, NULL, path.c_str(), args.c_str(), workdir.c_str(), SW_SHOWDEFAULT); + if (asadmin) { + ShellExecute(NULL, L"runas", path.c_str(), args.c_str(), workdir.c_str(), SW_SHOWDEFAULT); + } + else { + ShellExecute(NULL, NULL, path.c_str(), args.c_str(), workdir.c_str(), SW_SHOWDEFAULT); + } //Sleep(2000); return true; }