From 112f4bf92d0f1afd0eca2d2f4394f167d4d0913a Mon Sep 17 00:00:00 2001 From: Valentin Radu Date: Fri, 19 Nov 2021 18:57:32 +0200 Subject: [PATCH] Changed ep_setup command line and default behavior --- CHANGELOG.md | 1 + README.md | 6 ++--- ep_setup/ep_setup.c | 46 ++++++++++++++------------------- ep_setup_patch/ep_setup_patch.c | 2 +- version.h | 6 ++--- 5 files changed, 27 insertions(+), 34 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 576730f..692c1e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ Tested on build 22000.318 and 22000.346 (currently in Windows Insider beta and r * `ep-setup /extract "C:\test with space"` - extracts to `C:\test with space` directory * Taskbar toolbar layouts are preserved when switching between Windows 10 and Windows 11 taskbars and in general (these will be reset when installing this update but should be subsequently remembered) (#395) (.2) * Implemented option to toggle taskbar auto-hide when double clicking the main taskbar (#389) (.3) +* Running `ep-setup.exe` again while EP is already installed will now update the program to the latest version. To uninstall, as the previous behavior did, run `ep_setup.exe /uninstall` (.4) #### Feature enhancements diff --git a/README.md b/README.md index 364e0f7..b30a43c 100644 --- a/README.md +++ b/README.md @@ -42,13 +42,13 @@ Items marked with "bug" that are still "Open" represent known issues. Active wor ## Uninstalling -* Run `ep_setup.exe` again. -* Via "Programs and Features" in Control Panel, or "Apps and features" in the Settings app. +* Use "Programs and Features" in Control Panel, or "Apps and features" in the Settings app. +* Run `ep_setup.exe /uninstall`. ## Updating * The program features built-in updates: go to "Properties" - "Updates" to configure, check for and install the latest updates. -* Download latest setup file and run `ep_setup.exe /update_silent` +* Download the latest version's setup file and simply run it ## More information diff --git a/ep_setup/ep_setup.c b/ep_setup/ep_setup.c index 7b3cdfe..739ab70 100644 --- a/ep_setup/ep_setup.c +++ b/ep_setup/ep_setup.c @@ -301,8 +301,6 @@ int WINAPI wWinMain( &argc ); - bIsUpdate = (argc >= 1 && !_wcsicmp(wargv[0], L"/update_silent")); - WCHAR wszPath[MAX_PATH]; ZeroMemory(wszPath, MAX_PATH * sizeof(WCHAR)); @@ -338,6 +336,21 @@ int WINAPI wWinMain( return 0; } + bInstall = !(argc >= 1 && (!_wcsicmp(wargv[0], L"/uninstall") || !_wcsicmp(wargv[0], L"/uninstall_silent"))); + bIsUpdate = (argc >= 1 && !_wcsicmp(wargv[0], L"/update_silent")); + if (!bInstall && !_wcsicmp(wargv[0], L"/uninstall")) + { + if (MessageBoxW( + NULL, + L"Are you sure you want to remove " _T(PRODUCT_NAME) L" from your computer?", + _T(PRODUCT_NAME), + MB_YESNO | MB_DEFBUTTON2 | MB_ICONQUESTION + ) == IDNO) + { + exit(0); + } + } + if (!IsAppRunningAsAdminMode()) { WCHAR wszPath[MAX_PATH]; @@ -349,7 +362,7 @@ int WINAPI wWinMain( sei.cbSize = sizeof(sei); sei.lpVerb = L"runas"; sei.lpFile = wszPath; - sei.lpParameters = lpCmdLine; + sei.lpParameters = !bInstall ? L"/uninstall_silent" : lpCmdLine; sei.hwnd = NULL; sei.nShow = SW_NORMAL; if (!ShellExecuteExW(&sei)) @@ -363,28 +376,6 @@ int WINAPI wWinMain( } } - if (bOk) - { - bOk = GetWindowsDirectoryW(wszPath, MAX_PATH); - } - if (bOk) - { - wcscat_s(wszPath, MAX_PATH, L"\\dxgi.dll"); - bInstall = !FileExistsW(wszPath) || bIsUpdate; - } - if (!bInstall) - { - if (MessageBoxW( - NULL, - L"Are you sure you want to remove " _T(PRODUCT_NAME) L" from your computer?", - _T(PRODUCT_NAME), - MB_YESNO | MB_DEFBUTTON2 | MB_ICONQUESTION - ) == IDNO) - { - exit(0); - } - } - SHGetFolderPathW(NULL, SPECIAL_FOLDER, NULL, SHGFP_TYPE_CURRENT, wszPath); wcscat_s(wszPath, MAX_PATH, _T(APP_RELATIVE_PATH)); bOk = CreateDirectoryW(wszPath, NULL); @@ -566,8 +557,9 @@ int WINAPI wWinMain( } if (bOk) { - SHGetFolderPathW(NULL, SPECIAL_FOLDER, NULL, SHGFP_TYPE_CURRENT, wszPath); - wcscat_s(wszPath, MAX_PATH, _T(APP_RELATIVE_PATH) L"\\" _T(SETUP_UTILITY_NAME)); + wszPath[0] = L'"'; + SHGetFolderPathW(NULL, SPECIAL_FOLDER, NULL, SHGFP_TYPE_CURRENT, wszPath + 1); + wcscat_s(wszPath, MAX_PATH, _T(APP_RELATIVE_PATH) L"\\" _T(SETUP_UTILITY_NAME) L"\" /uninstall"); bOk = SetupUninstallEntry(bInstall, wszPath); } diff --git a/ep_setup_patch/ep_setup_patch.c b/ep_setup_patch/ep_setup_patch.c index a769b18..e43eba3 100644 --- a/ep_setup_patch/ep_setup_patch.c +++ b/ep_setup_patch/ep_setup_patch.c @@ -57,7 +57,7 @@ int WINAPI wWinMain( ShExecInfo.hwnd = NULL; ShExecInfo.lpVerb = L"runas"; ShExecInfo.lpFile = wszPath; - ShExecInfo.lpParameters = L"/update_silent"; + ShExecInfo.lpParameters = NULL; ShExecInfo.lpDirectory = NULL; ShExecInfo.nShow = SW_SHOW; ShExecInfo.hInstApp = NULL; diff --git a/version.h b/version.h index ea97186..4eefa44 100644 --- a/version.h +++ b/version.h @@ -1,7 +1,7 @@ #define VER_MAJOR 22000 #define VER_MINOR 318 #define VER_BUILD_HI 38 -#define VER_BUILD_LO 3 +#define VER_BUILD_LO 4 #define VER_FLAGS VS_FF_PRERELEASE @@ -12,5 +12,5 @@ #define VER_STR(arg) #arg // The String form of the version numbers -#define VER_FILE_STRING VALUE "FileVersion", "22000.318.38.3" -#define VER_PRODUCT_STRING VALUE "ProductVersion", "22000.318.38.3" +#define VER_FILE_STRING VALUE "FileVersion", "22000.318.38.4" +#define VER_PRODUCT_STRING VALUE "ProductVersion", "22000.318.38.4"