made the Reboot command first quit and then reboot
- fixed bug #989690 - the installer now denies reboots while running - the Reboot instruction no longer returns or sets the error flag - added .onRebootFailed which is called when Reboot fails - installer should now always clean-up when rebooting git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@3729 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
b5cab9b25f
commit
335fd47066
10 changed files with 100 additions and 58 deletions
|
@ -245,8 +245,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,LPSTR lpszCmdParam,
|
|||
|
||||
g_exec_flags.errlvl = -1;
|
||||
ret = ui_doinstall();
|
||||
if (g_exec_flags.errlvl != -1)
|
||||
ret = g_exec_flags.errlvl;
|
||||
|
||||
#ifdef NSIS_CONFIG_LOG
|
||||
#ifndef NSIS_CONFIG_LOG_ODS
|
||||
|
@ -257,17 +255,53 @@ end:
|
|||
|
||||
CleanUp();
|
||||
|
||||
if (m_Err)
|
||||
{
|
||||
my_MessageBox(m_Err, MB_OK | MB_ICONSTOP | (IDOK << 20));
|
||||
ret = 2;
|
||||
}
|
||||
|
||||
#if defined(NSIS_SUPPORT_ACTIVEXREG) || defined(NSIS_SUPPORT_CREATESHORTCUT)
|
||||
OleUninitialize();
|
||||
#endif
|
||||
|
||||
if (m_Err)
|
||||
{
|
||||
my_MessageBox(m_Err, MB_OK | MB_ICONSTOP | (IDOK << 20));
|
||||
ExitProcess(2);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef NSIS_SUPPORT_REBOOT
|
||||
if (g_exec_flags.reboot_called)
|
||||
{
|
||||
HANDLE h=GetModuleHandle("ADVAPI32.dll");
|
||||
if (h)
|
||||
{
|
||||
BOOL (WINAPI *OPT)(HANDLE, DWORD,PHANDLE);
|
||||
BOOL (WINAPI *LPV)(LPCTSTR,LPCTSTR,PLUID);
|
||||
BOOL (WINAPI *ATP)(HANDLE,BOOL,PTOKEN_PRIVILEGES,DWORD,PTOKEN_PRIVILEGES,PDWORD);
|
||||
OPT=(void*)GetProcAddress(h,"OpenProcessToken");
|
||||
LPV=(void*)GetProcAddress(h,"LookupPrivilegeValueA");
|
||||
ATP=(void*)GetProcAddress(h,"AdjustTokenPrivileges");
|
||||
if (OPT && LPV && ATP)
|
||||
{
|
||||
HANDLE hToken;
|
||||
TOKEN_PRIVILEGES tkp;
|
||||
if (OPT(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
|
||||
{
|
||||
LPV(NULL, SE_SHUTDOWN_NAME, &tkp.Privileges[0].Luid);
|
||||
tkp.PrivilegeCount = 1;
|
||||
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
|
||||
ATP(hToken, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES)NULL, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!ExitWindowsEx(EWX_REBOOT,0))
|
||||
ExecuteCallbackFunction(CB_ONREBOOTFAILED);
|
||||
}
|
||||
#endif//NSIS_SUPPORT_REBOOT
|
||||
|
||||
if (g_exec_flags.errlvl != -1)
|
||||
ret = g_exec_flags.errlvl;
|
||||
|
||||
ExitProcess(ret);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void NSISCALL CleanUp()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue