-/* See if we were launched from a console window. */\r
-static void check_console() {\r
- /* If we're running in a service context there will be no console window. */\r
- HWND console = GetConsoleWindow();\r
- if (! console) return;\r
+static int elevate(int argc, TCHAR **argv, unsigned long message) {\r
+ print_message(stderr, message);\r
+\r
+ SHELLEXECUTEINFO sei;\r
+ ZeroMemory(&sei, sizeof(sei));\r
+ sei.cbSize = sizeof(sei);\r
+ sei.lpVerb = _T("runas");\r
+ sei.lpFile = (TCHAR *) HeapAlloc(GetProcessHeap(), 0, PATH_LENGTH);\r
+ if (! sei.lpFile) {\r
+ print_message(stderr, NSSM_MESSAGE_OUT_OF_MEMORY, _T("GetModuleFileName()"), _T("elevate()"));\r
+ return 111;\r
+ }\r
+ GetModuleFileName(0, (TCHAR *) sei.lpFile, PATH_LENGTH);\r