2020-12-22 12:27:28 +02:00
|
|
|
#include <filesystem>
|
|
|
|
|
#include <fstream>
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <vector>
|
|
|
|
|
#include <Shlobj.h>
|
|
|
|
|
#include <winrt/Windows.Data.Json.h>
|
|
|
|
|
#include <winrt/Windows.Foundation.Collections.h>
|
2021-05-06 16:17:57 +03:00
|
|
|
#include <winrt/Windows.System.UserProfile.h>
|
|
|
|
|
#include <winrt/Windows.Globalization.h>
|
2020-12-22 12:27:28 +02:00
|
|
|
|
|
|
|
|
#include "ZipTools/ZipFolder.h"
|
2020-12-22 17:15:46 +03:00
|
|
|
#include <common/SettingsAPI/settings_helpers.h>
|
|
|
|
|
#include <common/utils/json.h>
|
|
|
|
|
#include <common/utils/timeutil.h>
|
2021-01-12 20:48:55 +02:00
|
|
|
#include <common/utils/exec.h>
|
2020-12-22 17:15:46 +03:00
|
|
|
|
2022-06-30 22:10:14 +02:00
|
|
|
#include "Package.h"
|
2020-12-22 17:15:46 +03:00
|
|
|
#include "ReportMonitorInfo.h"
|
2021-05-20 18:41:12 +03:00
|
|
|
#include "RegistryUtils.h"
|
2021-05-26 16:23:49 +03:00
|
|
|
#include "EventViewer.h"
|
2021-07-20 10:33:00 +03:00
|
|
|
#include "InstallationFolder.h"
|
2022-10-26 14:02:31 +01:00
|
|
|
#include "ReportGPOValues.h"
|
2021-05-26 16:23:49 +03:00
|
|
|
|
2020-12-22 12:27:28 +02:00
|
|
|
using namespace std;
|
|
|
|
|
using namespace std::filesystem;
|
|
|
|
|
using namespace winrt::Windows::Data::Json;
|
|
|
|
|
|
|
|
|
|
map<wstring, vector<wstring>> escapeInfo = {
|
|
|
|
|
{ L"FancyZones\\app-zone-history.json", { L"app-zone-history/app-path" } },
|
2023-11-23 11:46:07 +01:00
|
|
|
{ L"FancyZones\\settings.json", { L"properties/fancyzones_excluded_apps" } },
|
|
|
|
|
{ L"MouseWithoutBorders\\settings.json", { L"properties/SecurityKey" } }, // avoid leaking connection key
|
[KBM]Launch apps / URI with keyboard shortcuts, support chords (#30121)
* Working UI update with just runProgram Path and isRunProgram
* First working, basic. no args or path, or setting change detections.
* Revert and fixed.
* Some clean up, working with config file monitor
* Args and Start-in should be working.
* File monitor, quotes, xaml screens one
* Fixed enable/disable toogle from XAML
* Code cleanup.
* Betting logging.
* Cleanup, start of RunProgramDescriptor and usage of run_non_elevated/run_elevated
* Code moved to KeyboardEventHandlers, but not enabled since it won't build as is, needs elevation.h. Other testing..
* Key chords working, pretty much
* Added gui for elevation level, need to refresh on change...
* f: include shellapi.h and reference wil in KBMEL
* run_elevated/run_non_elevated sorted out. Working!
* Removed lots of old temp code.
* Fix some speling errors.
* Cleanup before trying to add a UI for the chord
* Added "DifferentUser" option
* Closer on UI for chords.
* Better UI, lots working.
* Clean up
* Text for “Allow chords” – needs to look better…
* Bugs and clean-up
* Cleanup
* Refactor and clean up.
* More clean up
* Some localization.
* Don’t show “Allow chords“ to the “to” shortcut
* Maybe better foreground after opening new app
* Better chord matching.
* Runprogram fix for stealing existing shortcut.
* Better runProgram stuff
* Temp commit
* Working well
* Toast test
* More toast
* Added File and Folder picker UI
* Pre-check on run program file exists.
* Refactor to SetupRunProgramControls
* Open URI UI is going.
* Open URI working well
* Open URI stuff working well
* Allowed AppSpecific shortcut and fixed backup/restore shortcut dups
* Fixed settings screen
* Start of code to find by name...
* UI fixed
* Small fixes
* Some single edit code working.
* UI getting better.
* Fixes
* Fixed and merge from main
* UI updates
* UI updates.
* UI stuff
* Fixed crash from move ui item locations.
* Fixed crash from move ui item locations.
* Added delete confirm
* Basic sound working.
* Localized some stuff
* Added sounds
* Better experiance when shortcut is in use.
* UI tweaks
* Fixed KBM ui for unicode shortcut not having ","
* Some clean up
* Cleanup
* Cleanup
* Fixed applyXamlStyling
* Added back stuff lost in merge
* applyXamlStyling, again
* Fixed crash on change from non shortcut to shortcut
* Update src/modules/keyboardmanager/KeyboardManagerEngineTest/KeyboardManagerEngineTest.vcxproj
* Fixed some spelling type issues.
* ImplementationLibrary 231216
* Comment bump to see if the Microsoft.Windows.ImplementationLibrary version thing gets picked up
* Correct, Microsoft.Windows.ImplementationLibrary, finally?
* Fixed two test that failed because we now allow key-chords.
* Removed shortcut sounds.
* use original behavior when "allow chords" is off in shortcut window
* fix crash when editing a shortcut that has apps specified for it
* split KBM chords with comma on dashboard page
* Fix some spelling items.
* More "spelling"
* Fix XAML styling
* align TextBlock and ToggleSwitch
* fix cutoff issue at the top
* increase ComboBox width
* Added *Unsupported* for backwards compat on config of KBM
* fix spellcheck
* Fix crash on Remap key screen
* Fixed Remap Keys ComboBox width too short.
* Removed KBM Single Edit mode, fixed crash.
* Fix Xaml with xaml cops
* Fix crash on setting "target app" for some types of shortcuts.
* Space to toggle chord, combobox back
* fix spellcheck
* fix some code nits
* Code review updates.
* Add exclusions to the bug report tool
* Code review and kill CloseAndEndTask
* Fix alignment / 3 comboboxes per row
* Fix daily telemetry events to exclude start app and open URI
* Add chords and remove app start and open uri from config telemetry
* comma instead of plus in human readable shortcut telemetry data
* Code review, restore default-old state when new row added in KBM
* Code review, restore default-old state when new row added in KBM, part 2
* Still show target app on Settings
* Only allow enabling chords for origin shortcuts
---------
Co-authored-by: Andrey Nekrasov <yuyoyuppe@users.noreply.github.com>
Co-authored-by: Jaime Bernardo <jaime@janeasystems.com>
2024-02-27 18:12:05 -05:00
|
|
|
{ L"Keyboard Manager\\default.json", {
|
|
|
|
|
L"remapKeysToText",
|
|
|
|
|
L"remapShortcutsToText",
|
|
|
|
|
L"remapShortcuts/global/runProgramFilePath",
|
|
|
|
|
L"remapShortcuts/global/runProgramArgs",
|
|
|
|
|
L"remapShortcuts/global/runProgramStartInDir",
|
|
|
|
|
L"remapShortcuts/global/openUri",
|
|
|
|
|
L"remapShortcuts/appSpecific/runProgramFilePath",
|
|
|
|
|
L"remapShortcuts/appSpecific/runProgramArgs",
|
|
|
|
|
L"remapShortcuts/appSpecific/runProgramStartInDir",
|
|
|
|
|
L"remapShortcuts/appSpecific/openUri",
|
|
|
|
|
} }, // avoid leaking personal information from text, URI or application mappings
|
[New Module] Workspaces (#34324)
* spell checker
* Adding OOBE Projects page
* changed the default hotkey
* module interface
* rename projects editor
* bug report tool
* installer
* gpo
* exit event constant
* extend search for projects by search over the containing apps' names
* [Projects] fix grammatical issue #43 (1 app - many apps)
* [Projects] Editor: Main page: fix layout if there are many apps, launch button not disappearing on the right side
* dsc
* github
* pipeline
* guid prefix
* [Projects] fixing general settings gpo handling in runner + minor changes
* arm build fix
* Do not allow saving project if name or applist is empty. Also minor UI changes
* version
* editor version
* spellcheck
* editor dll signing
* update projects names to filter them out
* shortcut saving fix
* [Projects] Editor: brining the highlighted app's icon into the foreground. + minor UI fixes
* spell checker
* spellcheck
* [Projects] re-implementing icon size calculation to have similar sized icons for every app.
* [projects] Adding info message for cases: there are no projects or no results for the search
* [Projects] Adding Edit button to the popup. + minor changes
* [Projects] Making popup having rounded corners
* changed "no projects" text color and position
* remove opening the first proj
* fix placing windows of the same app in the project
* [Projects] bringing back the breadcrumb on the editor page. Make it clickable.
* [Projects] optimizing click handlers
* [Projects] Removing not selected apps on save
* moved on thread executor to common
* moved display utils
* added convert rect
* unsigned monitor number
* set awareness
* app placement
* [Projects] Re-implementing preview drawing - one common image
* [Projects] fix boundary calculation, use DPI aware values
* fix launching with command line args
* Fix ARM64 CI build
* launch packaged apps using names when possible
* spell-check
* update packaged apps path
* projects editor single instance
* [Projects] Add Select all checkbox, Delete selected button
* Add Checkbox for per monitor selection
* modifying highlight in preview
* spell checker
* logs
* exclude help windows
https://github.com/JaneaSystems/PowerToys-DevProjects/issues/49
* Add intermediate step to project creation
* minor bugfix
* mutex fix
* modifying highlight for minimized apps
* Fixing bug: re-draw the preview on app deletion in the editor
* Adding helper class for getting the right bounds for screens
* spell checker
* spell checker
* Minor fixes in the capture dialog
* get dpi unaware screen bounds
* refactoring: added utils
* changed window filter
https://github.com/JaneaSystems/PowerToys-DevProjects/issues/2
* clean up
* refactoring
* projects common lib
* localizable default project prefix
* launcher resources
* clean up
* change snapshot project saving
https://github.com/JaneaSystems/PowerToys-DevProjects/issues/14
* changed project data
https://github.com/JaneaSystems/PowerToys-DevProjects/issues/14
* changed project creation save-cancel handles
https://github.com/JaneaSystems/PowerToys-DevProjects/issues/14
* spell-check
* Remove checkboxes, delete feature
* remove unused from the project
* get command line args in the snapshot
* minimized settings snap fix
* set window property after launching
* FZ: ignore projects launched windows
* Implementing major new features: remove button, position manipulation, arguments, admin, minimized, maximized
* modifying colors
* launcher project filters
* clean up
* Hide Admin checkbox
* hide WIP
* spell-check
* Revert "Hide Admin checkbox"
This reverts commit 3036df9d7fe48de6418b0ebeff6422d535cb25e2.
* get app elevated property
* Implementing Launch and Edit feature
* fixing: update of listed projects on the main page after hitting save in editor
* Fix for packaged app's icons
* fixing scroll speed issue
* change scroll speed to 15
* launch elevated apps
* minor fixes
* minor fix
* enhancing shortcut handling
* can-launch-elevated check
* projects module interface telemetry
* Implementing store of setting "order by".
* minor string correction
* moved projects data parsing
* telemetry
* add move apps checkbox
* notification about elevated apps
* restart unelevated
* move existing windows
* keep opened windows at the same positions
* handle powertoys settings
* use common theme
* fix corrupted data: project id and monitor id
* project launch on "launch and edit"
* clean up
* show screen numbers instead of monitor names
* launcher error messages
* fix default shortcut
* Adding launch button to projects settings, dashboard and flyout
* Adding new app which is launched when launching a project. It shows the status of the launch process
* spell checker
* Renaming Projects to App Layouts. Replacing only string values, not the variable names
* Re-ordering modules after Renaming Projects + spell checker
* setting window size according to the screen (making it bigger)
* commenting out feature "move apps if exist"
* spell checker
* Add ProjectsLauncherUI to signing
* opening apps in minimized state which are placed on a monitor, which is not found at the moment of launching
* consistent file name
* removed unused sln
* telemetry: create event
* WindowPosition comparison
* telemetry: edit event
* fix muted Launch as admin checkbox
* telemetry: delete event
* updated Edit telemetry event
* added invoke point to launcher args
* added utils
* parse invoke point
* replaced tuple with struct
* telemetry: launch event
* MonitorRect comparison
* resources
* rename: folders
* remove outdated
* rename: window property
* rename: files and folders
* rename: common data structures
* rename: telemetry namespace
* rename: workspaces data
* rename ProjectsLib -> WorkspacesLib
* rename: gpo
* rename: settings
* rename: launcher UI
* rename: other
* rename: pt run
* rename: fz
* rename: module interface
* rename: icon
* rename: snapshot tool
* rename: editor
* rename: common files
* rename: launcher
* rename: editor resources
* fix empty file crash
* rename: json
* rename: module interface
* fix custom actions build
* added launch editor event constant
* xaml formatting
* Add missing method defition to interop::Constants idl
Remove Any CPU config
* more .sln cleanup
* [Run][PowerToys] Fix Workspaces utility (#34336)
polished workspaces utility
* build fix - align CppWinRT version
* address PR comment: fix isdigit
* indentation
* address PR comment: rename function
* address PR comment: changed version for workspaces and revision
* added supported version definition
* addressPR comment: use BringToForeground
* address PR comments: updated projects
* address PR comment: uncomment gpo in settings
* address PR comment: rename oobe view
* update OOBE image with current module name
* moved AppUtils
* launching with AppUserModel.ID
* fixed module order in settings
* fix xaml formatting
* [Workspaces] Close launcher if there are failed launches. Plus adding new spinner gif
* fix topmost LauncherUI
* clean up
* UI closing
* BugReportTool - omit cmd arg data
* Delete icon on workspace removal
* Adding cancellation to launcher UI.
* reordered launching
* fix terminating UI
* Removing old shortcut on workspace renaming
* Sentence case labels
* get process path without waiting
* comment out unused
* remove unused argument
* logs
* New icon
* fix launch and edit for the new project
* fix launch and edit: save new project
* Update exe icons
---------
Co-authored-by: donlaci <laszlo@janeasystems.com>
Co-authored-by: Jaime Bernardo <jaime@janeasystems.com>
Co-authored-by: Stefan Markovic <stefan@janeasystems.com>
Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it>
Co-authored-by: Niels Laute <niels.laute@live.nl>
2024-08-23 09:28:13 +02:00
|
|
|
{ L"Workspaces/workspaces.json", { L"workspaces/applications/command-line-arguments" } },
|
2024-09-02 16:21:57 +02:00
|
|
|
{ L"AdvancedPaste/settings.json", {
|
|
|
|
|
L"properties/custom-actions/value/name",
|
|
|
|
|
L"properties/custom-actions/value/prompt"
|
|
|
|
|
} },
|
2020-12-22 12:27:28 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
vector<wstring> filesToDelete = {
|
2024-05-09 10:32:03 -04:00
|
|
|
L"AdvancedPaste\\lastQuery.json",
|
2020-12-24 17:05:32 +01:00
|
|
|
L"PowerToys Run\\Cache",
|
|
|
|
|
L"PowerRename\\replace-mru.json",
|
2021-01-19 18:43:28 +02:00
|
|
|
L"PowerRename\\search-mru.json",
|
|
|
|
|
L"PowerToys Run\\Settings\\UserSelectedRecord.json",
|
2024-09-19 09:12:24 -07:00
|
|
|
L"PowerToys Run\\Settings\\QueryHistory.json",
|
|
|
|
|
L"NewPlus\\Templates",
|
2020-12-22 12:27:28 +02:00
|
|
|
};
|
|
|
|
|
|
2021-05-20 18:41:12 +03:00
|
|
|
vector<wstring> GetXpathArray(wstring xpath)
|
2020-12-22 12:27:28 +02:00
|
|
|
{
|
|
|
|
|
vector<wstring> result;
|
|
|
|
|
wstring cur = L"";
|
|
|
|
|
for (auto ch : xpath)
|
|
|
|
|
{
|
|
|
|
|
if (ch == L'/')
|
|
|
|
|
{
|
|
|
|
|
result.push_back(cur);
|
|
|
|
|
cur = L"";
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cur += ch;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!cur.empty())
|
|
|
|
|
{
|
|
|
|
|
result.push_back(cur);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-20 18:41:12 +03:00
|
|
|
void HideByXPath(IJsonValue& val, vector<wstring>& xpathArray, int p)
|
2020-12-22 12:27:28 +02:00
|
|
|
{
|
|
|
|
|
if (val.ValueType() == JsonValueType::Array)
|
|
|
|
|
{
|
|
|
|
|
for (auto it : val.GetArray())
|
|
|
|
|
{
|
2021-05-20 18:41:12 +03:00
|
|
|
HideByXPath(it, xpathArray, p);
|
2020-12-22 12:27:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (p == xpathArray.size() - 1)
|
|
|
|
|
{
|
|
|
|
|
if (val.ValueType() == JsonValueType::Object)
|
|
|
|
|
{
|
|
|
|
|
auto obj = val.GetObjectW();
|
|
|
|
|
if (obj.HasKey(xpathArray[p]))
|
|
|
|
|
{
|
|
|
|
|
auto privateDatavalue = JsonValue::CreateStringValue(L"<private_data>");
|
|
|
|
|
obj.SetNamedValue(xpathArray[p], privateDatavalue);
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-12-22 17:15:46 +03:00
|
|
|
|
2020-12-22 12:27:28 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (val.ValueType() == JsonValueType::Object)
|
|
|
|
|
{
|
|
|
|
|
IJsonValue newVal;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
newVal = val.GetObjectW().GetNamedValue(xpathArray[p]);
|
|
|
|
|
}
|
|
|
|
|
catch (...)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2020-12-22 17:15:46 +03:00
|
|
|
|
2021-05-20 18:41:12 +03:00
|
|
|
HideByXPath(newVal, xpathArray, p + 1);
|
2020-12-22 12:27:28 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-20 18:41:12 +03:00
|
|
|
void HideForFile(const path& dir, const wstring& relativePath)
|
2020-12-22 12:27:28 +02:00
|
|
|
{
|
|
|
|
|
path jsonPath = dir;
|
|
|
|
|
jsonPath.append(relativePath);
|
|
|
|
|
auto jObject = json::from_file(jsonPath.wstring());
|
|
|
|
|
if (!jObject.has_value())
|
|
|
|
|
{
|
2020-12-24 12:27:49 +01:00
|
|
|
wprintf(L"Failed to parse file %s\n", jsonPath.c_str());
|
2020-12-22 17:15:46 +03:00
|
|
|
return;
|
2020-12-22 12:27:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JsonValue jValue = json::value(jObject.value());
|
|
|
|
|
for (auto xpath : escapeInfo[relativePath])
|
|
|
|
|
{
|
2021-05-20 18:41:12 +03:00
|
|
|
vector<wstring> xpathArray = GetXpathArray(xpath);
|
|
|
|
|
HideByXPath(jValue, xpathArray, 0);
|
2020-12-22 12:27:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
json::to_file(jsonPath.wstring(), jObject.value());
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-20 18:41:12 +03:00
|
|
|
bool DeleteFolder(wstring path)
|
2020-12-22 12:27:28 +02:00
|
|
|
{
|
|
|
|
|
error_code err;
|
|
|
|
|
remove_all(path, err);
|
|
|
|
|
if (err.value() != 0)
|
|
|
|
|
{
|
2020-12-24 12:27:49 +01:00
|
|
|
wprintf_s(L"Failed to delete %s. Error code: %d\n", path.c_str(), err.value());
|
2020-12-22 12:27:28 +02:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-20 18:41:12 +03:00
|
|
|
void HideUserPrivateInfo(const filesystem::path& dir)
|
2020-12-22 12:27:28 +02:00
|
|
|
{
|
|
|
|
|
// Replace data in json files
|
|
|
|
|
for (auto& it : escapeInfo)
|
|
|
|
|
{
|
2021-05-20 18:41:12 +03:00
|
|
|
HideForFile(dir, it.first);
|
2020-12-22 12:27:28 +02:00
|
|
|
}
|
|
|
|
|
|
2021-05-21 13:32:34 +03:00
|
|
|
// Delete files
|
2020-12-22 12:27:28 +02:00
|
|
|
for (auto it : filesToDelete)
|
|
|
|
|
{
|
|
|
|
|
auto path = dir;
|
|
|
|
|
path = path.append(it);
|
2021-05-20 18:41:12 +03:00
|
|
|
DeleteFolder(path);
|
2020-12-22 12:27:28 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-20 18:41:12 +03:00
|
|
|
void ReportWindowsVersion(const filesystem::path& tmpDir)
|
2020-12-22 12:27:28 +02:00
|
|
|
{
|
|
|
|
|
auto versionReportPath = tmpDir;
|
|
|
|
|
versionReportPath = versionReportPath.append("windows-version.txt");
|
2022-11-22 20:02:40 +00:00
|
|
|
OSVERSIONINFOEXW osInfo{};
|
2020-12-22 12:27:28 +02:00
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2020-12-22 17:15:46 +03:00
|
|
|
NTSTATUS(WINAPI * RtlGetVersion)
|
|
|
|
|
(LPOSVERSIONINFOEXW) = nullptr;
|
2023-02-08 14:01:40 +00:00
|
|
|
*reinterpret_cast<FARPROC*>(& RtlGetVersion) = GetProcAddress(GetModuleHandleA("ntdll"), "RtlGetVersion");
|
2020-12-22 17:15:46 +03:00
|
|
|
if (RtlGetVersion)
|
2020-12-22 12:27:28 +02:00
|
|
|
{
|
|
|
|
|
osInfo.dwOSVersionInfoSize = sizeof(osInfo);
|
|
|
|
|
RtlGetVersion(&osInfo);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (...)
|
|
|
|
|
{
|
2020-12-24 12:27:49 +01:00
|
|
|
printf("Failed to get windows version info\n");
|
2020-12-22 12:27:28 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
wofstream versionReport(versionReportPath);
|
|
|
|
|
versionReport << "MajorVersion: " << osInfo.dwMajorVersion << endl;
|
|
|
|
|
versionReport << "MinorVersion: " << osInfo.dwMinorVersion << endl;
|
|
|
|
|
versionReport << "BuildNumber: " << osInfo.dwBuildNumber << endl;
|
|
|
|
|
}
|
2022-03-16 14:39:00 +03:00
|
|
|
catch (...)
|
2020-12-22 12:27:28 +02:00
|
|
|
{
|
2020-12-24 12:27:49 +01:00
|
|
|
printf("Failed to write to %s\n", versionReportPath.string().c_str());
|
2020-12-22 12:27:28 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-20 18:41:12 +03:00
|
|
|
void ReportWindowsSettings(const filesystem::path& tmpDir)
|
2021-05-06 16:17:57 +03:00
|
|
|
{
|
|
|
|
|
std::wstring userLanguage;
|
|
|
|
|
std::wstring userLocale;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
const auto lang = winrt::Windows::System::UserProfile::GlobalizationPreferences::Languages().GetAt(0);
|
2022-03-16 14:39:00 +03:00
|
|
|
userLanguage = winrt::Windows::Globalization::Language{ lang }.DisplayName().c_str();
|
2021-05-06 16:17:57 +03:00
|
|
|
wchar_t localeName[LOCALE_NAME_MAX_LENGTH]{};
|
|
|
|
|
if (!LCIDToLocaleName(GetThreadLocale(), localeName, LOCALE_NAME_MAX_LENGTH, 0))
|
|
|
|
|
{
|
|
|
|
|
throw -1;
|
|
|
|
|
}
|
|
|
|
|
userLocale = localeName;
|
|
|
|
|
}
|
|
|
|
|
catch (...)
|
|
|
|
|
{
|
|
|
|
|
printf("Failed to get windows settings\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
wofstream settingsReport(tmpDir / "windows-settings.txt");
|
|
|
|
|
settingsReport << "Preferred user language: " << userLanguage << endl;
|
|
|
|
|
settingsReport << "User locale: " << userLocale << endl;
|
|
|
|
|
}
|
2022-03-16 14:39:00 +03:00
|
|
|
catch (...)
|
2021-05-06 16:17:57 +03:00
|
|
|
{
|
|
|
|
|
printf("Failed to write windows settings\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-20 18:41:12 +03:00
|
|
|
void ReportDotNetInstallationInfo(const filesystem::path& tmpDir)
|
2021-01-12 20:48:55 +02:00
|
|
|
{
|
|
|
|
|
auto dotnetInfoPath = tmpDir;
|
|
|
|
|
dotnetInfoPath.append("dotnet-installation-info.txt");
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
wofstream dotnetReport(dotnetInfoPath);
|
|
|
|
|
auto dotnetInfo = exec_and_read_output(LR"(dotnet --list-runtimes)");
|
|
|
|
|
if (!dotnetInfo.has_value())
|
|
|
|
|
{
|
|
|
|
|
printf("Failed to get dotnet installation information\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dotnetReport << dotnetInfo.value().c_str();
|
|
|
|
|
}
|
|
|
|
|
catch (...)
|
|
|
|
|
{
|
|
|
|
|
printf("Failed to report dotnet installation information");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-29 13:06:12 +03:00
|
|
|
void ReportVCMLogs(const filesystem::path& tmpDir, const filesystem::path& reportDir)
|
|
|
|
|
{
|
|
|
|
|
error_code ec;
|
|
|
|
|
copy(tmpDir / "PowerToysVideoConference_x86.log", reportDir, ec);
|
|
|
|
|
copy(tmpDir / "PowerToysVideoConference_x64.log", reportDir, ec);
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-16 14:39:00 +03:00
|
|
|
void ReportInstallerLogs(const filesystem::path& tmpDir, const filesystem::path& reportDir)
|
|
|
|
|
{
|
2023-02-22 10:06:59 +01:00
|
|
|
const char* bootstrapperLogFilePrefix = "powertoys-bootstrapper-msi-";
|
|
|
|
|
const char* PTLogFilePrefix = "PowerToysMSIInstaller_";
|
2022-03-16 14:39:00 +03:00
|
|
|
|
|
|
|
|
for (auto& entry : directory_iterator{ tmpDir })
|
|
|
|
|
{
|
|
|
|
|
std::error_code ec;
|
|
|
|
|
if (entry.is_directory(ec) || !entry.path().has_filename())
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const auto fileName = entry.path().filename().string();
|
2023-02-22 10:06:59 +01:00
|
|
|
if (!fileName.starts_with(bootstrapperLogFilePrefix) && !fileName.starts_with(PTLogFilePrefix))
|
2022-03-16 14:39:00 +03:00
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
copy(entry.path(), reportDir / fileName, ec);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-22 12:27:28 +02:00
|
|
|
int wmain(int argc, wchar_t* argv[], wchar_t*)
|
|
|
|
|
{
|
|
|
|
|
// Get path to save zip
|
|
|
|
|
wstring saveZipPath;
|
|
|
|
|
if (argc > 1)
|
|
|
|
|
{
|
|
|
|
|
saveZipPath = argv[1];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
wchar_t buffer[MAX_PATH];
|
|
|
|
|
if (SHGetSpecialFolderPath(HWND_DESKTOP, buffer, CSIDL_DESKTOP, FALSE))
|
|
|
|
|
{
|
|
|
|
|
saveZipPath = buffer;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2020-12-24 12:27:49 +01:00
|
|
|
printf("Failed to retrieve the desktop path. Error code: %d\n", GetLastError());
|
|
|
|
|
return 1;
|
2020-12-22 12:27:28 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-24 12:27:49 +01:00
|
|
|
auto settingsRootPath = PTSettingsHelper::get_root_save_folder_location();
|
2022-08-16 19:32:49 +02:00
|
|
|
settingsRootPath += L"\\";
|
|
|
|
|
|
|
|
|
|
auto localLowPath = PTSettingsHelper::get_local_low_folder_location();
|
|
|
|
|
localLowPath += L"\\logs\\";
|
2020-12-22 17:15:46 +03:00
|
|
|
|
2021-06-29 13:06:12 +03:00
|
|
|
const auto tempDir = temp_directory_path();
|
|
|
|
|
auto reportDir = temp_directory_path() / "PowerToys\\";
|
|
|
|
|
if (!DeleteFolder(reportDir))
|
2020-12-22 12:27:28 +02:00
|
|
|
{
|
2020-12-24 12:27:49 +01:00
|
|
|
printf("Failed to delete temp folder\n");
|
2020-12-22 12:27:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2021-06-29 13:06:12 +03:00
|
|
|
copy(settingsRootPath, reportDir, copy_options::recursive);
|
2022-03-16 14:39:00 +03:00
|
|
|
|
2020-12-22 17:15:46 +03:00
|
|
|
// Remove updates folder contents
|
2021-06-29 13:06:12 +03:00
|
|
|
DeleteFolder(reportDir / "Updates");
|
2020-12-22 12:27:28 +02:00
|
|
|
}
|
2022-08-16 19:32:49 +02:00
|
|
|
|
2020-12-22 12:27:28 +02:00
|
|
|
catch (...)
|
|
|
|
|
{
|
2020-12-24 12:27:49 +01:00
|
|
|
printf("Failed to copy PowerToys folder\n");
|
2020-12-22 12:27:28 +02:00
|
|
|
return 1;
|
|
|
|
|
}
|
2020-12-22 17:15:46 +03:00
|
|
|
|
2022-08-16 19:32:49 +02:00
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
copy(localLowPath, reportDir, copy_options::recursive);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
catch (...)
|
|
|
|
|
{
|
|
|
|
|
printf("Failed to copy logs saved in LocalLow\n");
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-01 18:12:28 +03:00
|
|
|
#ifndef _DEBUG
|
2021-07-20 10:33:00 +03:00
|
|
|
InstallationFolder::ReportStructure(reportDir);
|
2021-09-01 18:12:28 +03:00
|
|
|
#endif
|
2021-07-20 10:33:00 +03:00
|
|
|
|
2020-12-22 17:15:46 +03:00
|
|
|
// Hide sensitive information
|
2021-06-29 13:06:12 +03:00
|
|
|
HideUserPrivateInfo(reportDir);
|
2020-12-22 12:27:28 +02:00
|
|
|
|
2021-05-06 16:17:57 +03:00
|
|
|
// Write windows settings to the temporary folder
|
2021-06-29 13:06:12 +03:00
|
|
|
ReportWindowsSettings(reportDir);
|
2021-05-06 16:17:57 +03:00
|
|
|
|
2020-12-22 12:27:28 +02:00
|
|
|
// Write monitors info to the temporary folder
|
2021-06-29 13:06:12 +03:00
|
|
|
ReportMonitorInfo(reportDir);
|
2020-12-22 12:27:28 +02:00
|
|
|
|
|
|
|
|
// Write windows version info to the temporary folder
|
2021-06-29 13:06:12 +03:00
|
|
|
ReportWindowsVersion(reportDir);
|
2020-12-22 12:27:28 +02:00
|
|
|
|
2021-01-12 20:48:55 +02:00
|
|
|
// Write dotnet installation info to the temporary folder
|
2021-06-29 13:06:12 +03:00
|
|
|
ReportDotNetInstallationInfo(reportDir);
|
2021-01-12 20:48:55 +02:00
|
|
|
|
2021-01-21 17:01:28 +01:00
|
|
|
// Write registry to the temporary folder
|
2021-06-29 13:06:12 +03:00
|
|
|
ReportRegistry(reportDir);
|
2021-05-20 18:41:12 +03:00
|
|
|
|
2022-10-26 14:02:31 +01:00
|
|
|
// Write gpo policies to the temporary folder
|
|
|
|
|
ReportGPOValues(reportDir);
|
|
|
|
|
|
2021-05-20 18:41:12 +03:00
|
|
|
// Write compatibility tab info to the temporary folder
|
2021-06-29 13:06:12 +03:00
|
|
|
ReportCompatibilityTab(reportDir);
|
2021-01-21 17:01:28 +01:00
|
|
|
|
2021-05-26 16:23:49 +03:00
|
|
|
// Write event viewer logs info to the temporary folder
|
2021-06-29 13:06:12 +03:00
|
|
|
EventViewer::ReportEventViewerInfo(reportDir);
|
|
|
|
|
|
|
|
|
|
ReportVCMLogs(tempDir, reportDir);
|
2022-03-16 14:39:00 +03:00
|
|
|
|
|
|
|
|
ReportInstallerLogs(tempDir, reportDir);
|
2021-05-26 16:23:49 +03:00
|
|
|
|
2022-06-30 22:10:14 +02:00
|
|
|
ReportInstalledContextMenuPackages(reportDir);
|
|
|
|
|
|
2020-12-22 12:27:28 +02:00
|
|
|
// Zip folder
|
|
|
|
|
auto zipPath = path::path(saveZipPath);
|
2020-12-22 17:15:46 +03:00
|
|
|
|
2020-12-22 12:27:28 +02:00
|
|
|
try
|
|
|
|
|
{
|
2021-06-29 13:06:12 +03:00
|
|
|
ZipFolder(zipPath, reportDir);
|
2020-12-22 12:27:28 +02:00
|
|
|
}
|
|
|
|
|
catch (...)
|
|
|
|
|
{
|
2020-12-24 12:27:49 +01:00
|
|
|
printf("Failed to zip folder\n");
|
2020-12-22 12:27:28 +02:00
|
|
|
return 1;
|
|
|
|
|
}
|
2020-12-22 17:15:46 +03:00
|
|
|
|
2021-06-29 13:06:12 +03:00
|
|
|
DeleteFolder(reportDir);
|
2020-12-22 12:27:28 +02:00
|
|
|
return 0;
|
2021-01-21 17:01:28 +01:00
|
|
|
}
|