diff --git a/WeaselSetup/WeaselSetup.cpp b/WeaselSetup/WeaselSetup.cpp index e9a1e56e7..43286ecfb 100644 --- a/WeaselSetup/WeaselSetup.cpp +++ b/WeaselSetup/WeaselSetup.cpp @@ -136,6 +136,12 @@ static int CustomInstall(bool installing) { return 0; } +LPCTSTR GetParamByPrefix(LPCTSTR lpCmdLine, LPCTSTR prefix) { + return (wcsncmp(lpCmdLine, prefix, wcslen(prefix)) == 0) + ? (lpCmdLine + wcslen(prefix)) + : 0; +} + static int Run(LPTSTR lpCmdLine) { constexpr bool silent = true; constexpr bool old_ime_support = false; @@ -147,6 +153,11 @@ static int Run(LPTSTR lpCmdLine) { return RestartAsAdmin(lpCmdLine); } + if (auto res = GetParamByPrefix(lpCmdLine, L"/userdir:")) { + return SetRegKeyValue(HKEY_CURRENT_USER, L"Software\\Rime\\weasel", + L"RimeUserDir", res, REG_SZ); + } + if (!wcscmp(L"/ls", lpCmdLine)) { return SetRegKeyValue(HKEY_CURRENT_USER, L"Software\\Rime\\weasel", L"Language", L"chs", REG_SZ);