Hi,
Runing my exe-file in NSIS with command 'Exec' exe-file recieves 'SW_SHOWMINIMIZED'
Exec 'test.exe'..
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR cmdline, int showcmd)....
And i can't understand why 🙁
I expected recieve SW_SHOWNORMAL or SW_SHOWDEFAULT
Using ExecShell i can set parameter 'SW_SHOWNORMAL' and everything is ok but its elevated process (
Could you explain me what i do wrong?
thanks
Runing exe file by Exec/ExecShell
2 posts
Did you start the NSIS installer minimized?
Exec does not specify STARTF_USESHOWWINDOW in its STARTINFO when calling CreateProcess so what happens might be up to your C-runtime (WinMain is not the real start of a Windows application). However, if STARTF_USESHOWWINDOW is set then ShowWindow() is supposed to use the value from STARTINFO and not the parameter you passed it the first time you call it! Is it possible the problem is in your app?
With a simple app like this:
Exec does not specify STARTF_USESHOWWINDOW in its STARTINFO when calling CreateProcess so what happens might be up to your C-runtime (WinMain is not the real start of a Windows application). However, if STARTF_USESHOWWINDOW is set then ShowWindow() is supposed to use the value from STARTINFO and not the parameter you passed it the first time you call it! Is it possible the problem is in your app?
With a simple app like this:
TRACE3A(...) {...}and this NSIS code:
... WinMainCRTStartup()
{
STARTUPINFO si;
si.cb = sizeof(si), si.wShowWindow = 0x666;
GetStartupInfo(&si);
TRACE3A("cb=%u dwFlags=%#x wShowWindow=%#x\n", si.cb, si.dwFlags, si.wShowWindow);
HWND hwnd = CreateWindowEx(0, TEXT("STATIC"), 0, WS_OVERLAPPEDWINDOW|WS_SYSMENU, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, 0, 0);
ShowWindow(hwnd, SW_SHOWNORMAL);
SetTimer(hwnd, 1, 3333, (TIMERPROC)ExitProcess); // This is a super ugly hack, don't ever do this
for (MSG msg; IsWindow(hwnd) && GetMessage(&msg, 0, 0, 0)😉 DispatchMessage(&msg); // Another hack!
ExitProcess(0);
}
Exec '"$temp\test.exe"'I get this:
!include WinMessages.nsh
System::Call 'KERNEL32::WinExec(m "$temp\test.exe", i ${SW_SHOWMINNOACTIVE})' ; Note: There is no Unicode version of this function!
cb=68 dwFlags=0x0 wShowWindow=0x0You complaints about ExecShell are strange. If UAC is on then the only scenario where ExecShell will elevate and Exec will start normally is if you are not a member of the administrators group and the requested execution level is set to highestAvailable.
cb=68 dwFlags=0x1 wShowWindow=0x7