Files
PowerToys/src/settings-ui/Settings.UI/ViewModels/CmdNotFoundViewModel.cs

261 lines
9.9 KiB
C#
Raw Normal View History

Introduce Command Not Found module (#26319) * Introduce Command Not Found module * rewrite module to depend on WinGet PowerShell module * address Dongbo's feedback * try and implement settings UI * fix SUI build; try and store PowerShell object * add and use object pool * apply Dongbo's feedback * add warm up; implement IPooledObjectPolicy * Add module interface * WIP trying to import module from settings * Add EnableModule.ps1 * spellcheck * spellcheck again * Installer. Add DisableModule.ps1 * Fix styling * Give the user some output from installing * Prettify the Settings controls * Add button to check PowerShell 7's version * Fix Settings Assets paths * Fix PowerShell 7 output * Make module enable and disable scripts give better information * Fix spellcheck * Fix image files and placeholders * Don't remove CmdNotFound on upgrade and don't fail on uninstall of CmdNotFound * Consistent install module scripts location on debug and installed * installer: Avoid messageboxes and hide powershell on uninstalling CmdNotFound * Fix psd1 file resolution when installed * Fix spellcheck * Add telemetry events * Fix gpo files * If GPO is set, enable/disable module on PT start depending on gpo value * Cleanup module interface * Cleanup settings code * If GPO is set, disable Settings page logic * Adding icons * Update settings UI and strings * Add telemetry for suggestions and feedbacks * Fix sln file * Fix build * minor fixes * Updating icon * Remove global.json * Remove unused PowerShell dependency * Don't use preview version of Automation and fix NOTICE * Fix signing * Fix NOTICE.md * Fix version checking for getfilesiginforedist.dll * Fix spellchecker * Fix README.md * Fix false positives section in expect.txt * Add logs to module interface --------- Co-authored-by: Stefan Markovic <stefan@janeasystems.com> Co-authored-by: Jaime Bernardo <jaime@janeasystems.com> Co-authored-by: Niels Laute <niels.laute@live.nl>
2024-01-03 07:43:42 -08:00
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using global::PowerToys.GPOWrapper;
[CmdNotFound]Improve installation workflow (#30727) * [CmdNotFound]Improve installation workflow * Fix typo * Fix XAML styling * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Don't create window for checking requirements * Hide install/uninstall buttons for CmdNotFound module * Also install winget before Powershell 7 * Better detect processor architecture * Fix spellcheck * [CMDNotFound] UX improvements (#30740) * UI improvements * Updated label * Update CmdNotFoundPage.xaml * Update CmdNotFoundPage.xaml * Update CmdNotFoundPage.xaml * Better version detection * Add some logging * Add missing package install that's a prerequisite for winget * Remove unused AllExperiments include * Fix Logger library include * Update PATH Environment variable after installing PS * Fix OOBE UI spacing * Use Invoke-WebRequest to get the deps and then install them from local path * Spellcheck * TEMP -> TMP * User path is supposed to come after machine path --------- Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> Co-authored-by: Niels Laute <niels.laute@live.nl> Co-authored-by: Stefan Markovic <stefan@janeasystems.com>
2024-01-05 09:26:49 +00:00
using ManagedCommon;
Introduce Command Not Found module (#26319) * Introduce Command Not Found module * rewrite module to depend on WinGet PowerShell module * address Dongbo's feedback * try and implement settings UI * fix SUI build; try and store PowerShell object * add and use object pool * apply Dongbo's feedback * add warm up; implement IPooledObjectPolicy * Add module interface * WIP trying to import module from settings * Add EnableModule.ps1 * spellcheck * spellcheck again * Installer. Add DisableModule.ps1 * Fix styling * Give the user some output from installing * Prettify the Settings controls * Add button to check PowerShell 7's version * Fix Settings Assets paths * Fix PowerShell 7 output * Make module enable and disable scripts give better information * Fix spellcheck * Fix image files and placeholders * Don't remove CmdNotFound on upgrade and don't fail on uninstall of CmdNotFound * Consistent install module scripts location on debug and installed * installer: Avoid messageboxes and hide powershell on uninstalling CmdNotFound * Fix psd1 file resolution when installed * Fix spellcheck * Add telemetry events * Fix gpo files * If GPO is set, enable/disable module on PT start depending on gpo value * Cleanup module interface * Cleanup settings code * If GPO is set, disable Settings page logic * Adding icons * Update settings UI and strings * Add telemetry for suggestions and feedbacks * Fix sln file * Fix build * minor fixes * Updating icon * Remove global.json * Remove unused PowerShell dependency * Don't use preview version of Automation and fix NOTICE * Fix signing * Fix NOTICE.md * Fix version checking for getfilesiginforedist.dll * Fix spellchecker * Fix README.md * Fix false positives section in expect.txt * Add logs to module interface --------- Co-authored-by: Stefan Markovic <stefan@janeasystems.com> Co-authored-by: Jaime Bernardo <jaime@janeasystems.com> Co-authored-by: Niels Laute <niels.laute@live.nl>
2024-01-03 07:43:42 -08:00
using Microsoft.PowerToys.Settings.UI.Library.Helpers;
using Microsoft.PowerToys.Settings.UI.Library.Telemetry.Events;
using Microsoft.PowerToys.Settings.UI.Library.ViewModels.Commands;
using Microsoft.PowerToys.Telemetry;
namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
public class CmdNotFoundViewModel : Observable
{
[CmdNotFound]Improve installation workflow (#30727) * [CmdNotFound]Improve installation workflow * Fix typo * Fix XAML styling * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Don't create window for checking requirements * Hide install/uninstall buttons for CmdNotFound module * Also install winget before Powershell 7 * Better detect processor architecture * Fix spellcheck * [CMDNotFound] UX improvements (#30740) * UI improvements * Updated label * Update CmdNotFoundPage.xaml * Update CmdNotFoundPage.xaml * Update CmdNotFoundPage.xaml * Better version detection * Add some logging * Add missing package install that's a prerequisite for winget * Remove unused AllExperiments include * Fix Logger library include * Update PATH Environment variable after installing PS * Fix OOBE UI spacing * Use Invoke-WebRequest to get the deps and then install them from local path * Spellcheck * TEMP -> TMP * User path is supposed to come after machine path --------- Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> Co-authored-by: Niels Laute <niels.laute@live.nl> Co-authored-by: Stefan Markovic <stefan@janeasystems.com>
2024-01-05 09:26:49 +00:00
public ButtonClickCommand CheckRequirementsEventHandler => new ButtonClickCommand(CheckCommandNotFoundRequirements);
public ButtonClickCommand InstallPowerShell7EventHandler => new ButtonClickCommand(InstallPowerShell7);
public ButtonClickCommand InstallWinGetClientModuleEventHandler => new ButtonClickCommand(InstallWinGetClientModule);
Introduce Command Not Found module (#26319) * Introduce Command Not Found module * rewrite module to depend on WinGet PowerShell module * address Dongbo's feedback * try and implement settings UI * fix SUI build; try and store PowerShell object * add and use object pool * apply Dongbo's feedback * add warm up; implement IPooledObjectPolicy * Add module interface * WIP trying to import module from settings * Add EnableModule.ps1 * spellcheck * spellcheck again * Installer. Add DisableModule.ps1 * Fix styling * Give the user some output from installing * Prettify the Settings controls * Add button to check PowerShell 7's version * Fix Settings Assets paths * Fix PowerShell 7 output * Make module enable and disable scripts give better information * Fix spellcheck * Fix image files and placeholders * Don't remove CmdNotFound on upgrade and don't fail on uninstall of CmdNotFound * Consistent install module scripts location on debug and installed * installer: Avoid messageboxes and hide powershell on uninstalling CmdNotFound * Fix psd1 file resolution when installed * Fix spellcheck * Add telemetry events * Fix gpo files * If GPO is set, enable/disable module on PT start depending on gpo value * Cleanup module interface * Cleanup settings code * If GPO is set, disable Settings page logic * Adding icons * Update settings UI and strings * Add telemetry for suggestions and feedbacks * Fix sln file * Fix build * minor fixes * Updating icon * Remove global.json * Remove unused PowerShell dependency * Don't use preview version of Automation and fix NOTICE * Fix signing * Fix NOTICE.md * Fix version checking for getfilesiginforedist.dll * Fix spellchecker * Fix README.md * Fix false positives section in expect.txt * Add logs to module interface --------- Co-authored-by: Stefan Markovic <stefan@janeasystems.com> Co-authored-by: Jaime Bernardo <jaime@janeasystems.com> Co-authored-by: Niels Laute <niels.laute@live.nl>
2024-01-03 07:43:42 -08:00
public ButtonClickCommand InstallModuleEventHandler => new ButtonClickCommand(InstallModule);
public ButtonClickCommand UninstallModuleEventHandler => new ButtonClickCommand(UninstallModule);
private GpoRuleConfigured _enabledGpoRuleConfiguration;
private bool _enabledStateIsGPOConfigured;
public static string AssemblyDirectory
{
get
{
string codeBase = Assembly.GetExecutingAssembly().Location;
UriBuilder uri = new UriBuilder(codeBase);
string path = Uri.UnescapeDataString(uri.Path);
return Path.GetDirectoryName(path);
}
}
public CmdNotFoundViewModel()
{
InitializeEnabledValue();
}
private void InitializeEnabledValue()
{
_enabledGpoRuleConfiguration = GPOWrapper.GetConfiguredCmdNotFoundEnabledValue();
if (_enabledGpoRuleConfiguration == GpoRuleConfigured.Disabled || _enabledGpoRuleConfiguration == GpoRuleConfigured.Enabled)
{
// Get the enabled state from GPO.
_enabledStateIsGPOConfigured = true;
}
[CmdNotFound]Improve installation workflow (#30727) * [CmdNotFound]Improve installation workflow * Fix typo * Fix XAML styling * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Don't create window for checking requirements * Hide install/uninstall buttons for CmdNotFound module * Also install winget before Powershell 7 * Better detect processor architecture * Fix spellcheck * [CMDNotFound] UX improvements (#30740) * UI improvements * Updated label * Update CmdNotFoundPage.xaml * Update CmdNotFoundPage.xaml * Update CmdNotFoundPage.xaml * Better version detection * Add some logging * Add missing package install that's a prerequisite for winget * Remove unused AllExperiments include * Fix Logger library include * Update PATH Environment variable after installing PS * Fix OOBE UI spacing * Use Invoke-WebRequest to get the deps and then install them from local path * Spellcheck * TEMP -> TMP * User path is supposed to come after machine path --------- Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> Co-authored-by: Niels Laute <niels.laute@live.nl> Co-authored-by: Stefan Markovic <stefan@janeasystems.com>
2024-01-05 09:26:49 +00:00
CheckCommandNotFoundRequirements();
Introduce Command Not Found module (#26319) * Introduce Command Not Found module * rewrite module to depend on WinGet PowerShell module * address Dongbo's feedback * try and implement settings UI * fix SUI build; try and store PowerShell object * add and use object pool * apply Dongbo's feedback * add warm up; implement IPooledObjectPolicy * Add module interface * WIP trying to import module from settings * Add EnableModule.ps1 * spellcheck * spellcheck again * Installer. Add DisableModule.ps1 * Fix styling * Give the user some output from installing * Prettify the Settings controls * Add button to check PowerShell 7's version * Fix Settings Assets paths * Fix PowerShell 7 output * Make module enable and disable scripts give better information * Fix spellcheck * Fix image files and placeholders * Don't remove CmdNotFound on upgrade and don't fail on uninstall of CmdNotFound * Consistent install module scripts location on debug and installed * installer: Avoid messageboxes and hide powershell on uninstalling CmdNotFound * Fix psd1 file resolution when installed * Fix spellcheck * Add telemetry events * Fix gpo files * If GPO is set, enable/disable module on PT start depending on gpo value * Cleanup module interface * Cleanup settings code * If GPO is set, disable Settings page logic * Adding icons * Update settings UI and strings * Add telemetry for suggestions and feedbacks * Fix sln file * Fix build * minor fixes * Updating icon * Remove global.json * Remove unused PowerShell dependency * Don't use preview version of Automation and fix NOTICE * Fix signing * Fix NOTICE.md * Fix version checking for getfilesiginforedist.dll * Fix spellchecker * Fix README.md * Fix false positives section in expect.txt * Add logs to module interface --------- Co-authored-by: Stefan Markovic <stefan@janeasystems.com> Co-authored-by: Jaime Bernardo <jaime@janeasystems.com> Co-authored-by: Niels Laute <niels.laute@live.nl>
2024-01-03 07:43:42 -08:00
}
private string _commandOutputLog;
public string CommandOutputLog
{
get => _commandOutputLog;
set
{
if (_commandOutputLog != value)
{
_commandOutputLog = value;
OnPropertyChanged(nameof(CommandOutputLog));
}
}
}
[CmdNotFound]Improve installation workflow (#30727) * [CmdNotFound]Improve installation workflow * Fix typo * Fix XAML styling * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Don't create window for checking requirements * Hide install/uninstall buttons for CmdNotFound module * Also install winget before Powershell 7 * Better detect processor architecture * Fix spellcheck * [CMDNotFound] UX improvements (#30740) * UI improvements * Updated label * Update CmdNotFoundPage.xaml * Update CmdNotFoundPage.xaml * Update CmdNotFoundPage.xaml * Better version detection * Add some logging * Add missing package install that's a prerequisite for winget * Remove unused AllExperiments include * Fix Logger library include * Update PATH Environment variable after installing PS * Fix OOBE UI spacing * Use Invoke-WebRequest to get the deps and then install them from local path * Spellcheck * TEMP -> TMP * User path is supposed to come after machine path --------- Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> Co-authored-by: Niels Laute <niels.laute@live.nl> Co-authored-by: Stefan Markovic <stefan@janeasystems.com>
2024-01-05 09:26:49 +00:00
private bool _isPowerShell7Detected;
public bool IsPowerShell7Detected
{
get => _isPowerShell7Detected;
set
{
if (_isPowerShell7Detected != value)
{
_isPowerShell7Detected = value;
OnPropertyChanged(nameof(IsPowerShell7Detected));
}
}
}
private bool _isWinGetClientModuleDetected;
public bool IsWinGetClientModuleDetected
{
get => _isWinGetClientModuleDetected;
set
{
if (_isWinGetClientModuleDetected != value)
{
_isWinGetClientModuleDetected = value;
OnPropertyChanged(nameof(IsWinGetClientModuleDetected));
}
}
}
private bool _isCommandNotFoundModuleInstalled;
public bool IsCommandNotFoundModuleInstalled
{
get => _isCommandNotFoundModuleInstalled;
set
{
if (_isCommandNotFoundModuleInstalled != value)
{
_isCommandNotFoundModuleInstalled = value;
OnPropertyChanged(nameof(IsCommandNotFoundModuleInstalled));
}
}
}
Introduce Command Not Found module (#26319) * Introduce Command Not Found module * rewrite module to depend on WinGet PowerShell module * address Dongbo's feedback * try and implement settings UI * fix SUI build; try and store PowerShell object * add and use object pool * apply Dongbo's feedback * add warm up; implement IPooledObjectPolicy * Add module interface * WIP trying to import module from settings * Add EnableModule.ps1 * spellcheck * spellcheck again * Installer. Add DisableModule.ps1 * Fix styling * Give the user some output from installing * Prettify the Settings controls * Add button to check PowerShell 7's version * Fix Settings Assets paths * Fix PowerShell 7 output * Make module enable and disable scripts give better information * Fix spellcheck * Fix image files and placeholders * Don't remove CmdNotFound on upgrade and don't fail on uninstall of CmdNotFound * Consistent install module scripts location on debug and installed * installer: Avoid messageboxes and hide powershell on uninstalling CmdNotFound * Fix psd1 file resolution when installed * Fix spellcheck * Add telemetry events * Fix gpo files * If GPO is set, enable/disable module on PT start depending on gpo value * Cleanup module interface * Cleanup settings code * If GPO is set, disable Settings page logic * Adding icons * Update settings UI and strings * Add telemetry for suggestions and feedbacks * Fix sln file * Fix build * minor fixes * Updating icon * Remove global.json * Remove unused PowerShell dependency * Don't use preview version of Automation and fix NOTICE * Fix signing * Fix NOTICE.md * Fix version checking for getfilesiginforedist.dll * Fix spellchecker * Fix README.md * Fix false positives section in expect.txt * Add logs to module interface --------- Co-authored-by: Stefan Markovic <stefan@janeasystems.com> Co-authored-by: Jaime Bernardo <jaime@janeasystems.com> Co-authored-by: Niels Laute <niels.laute@live.nl>
2024-01-03 07:43:42 -08:00
public bool IsEnabledGpoConfigured
{
get => _enabledStateIsGPOConfigured;
}
[CmdNotFound]Improve installation workflow (#30727) * [CmdNotFound]Improve installation workflow * Fix typo * Fix XAML styling * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Don't create window for checking requirements * Hide install/uninstall buttons for CmdNotFound module * Also install winget before Powershell 7 * Better detect processor architecture * Fix spellcheck * [CMDNotFound] UX improvements (#30740) * UI improvements * Updated label * Update CmdNotFoundPage.xaml * Update CmdNotFoundPage.xaml * Update CmdNotFoundPage.xaml * Better version detection * Add some logging * Add missing package install that's a prerequisite for winget * Remove unused AllExperiments include * Fix Logger library include * Update PATH Environment variable after installing PS * Fix OOBE UI spacing * Use Invoke-WebRequest to get the deps and then install them from local path * Spellcheck * TEMP -> TMP * User path is supposed to come after machine path --------- Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> Co-authored-by: Niels Laute <niels.laute@live.nl> Co-authored-by: Stefan Markovic <stefan@janeasystems.com>
2024-01-05 09:26:49 +00:00
public string RunPowerShellScript(string powershellExecutable, string powershellArguments, bool hidePowerShellWindow = false)
Introduce Command Not Found module (#26319) * Introduce Command Not Found module * rewrite module to depend on WinGet PowerShell module * address Dongbo's feedback * try and implement settings UI * fix SUI build; try and store PowerShell object * add and use object pool * apply Dongbo's feedback * add warm up; implement IPooledObjectPolicy * Add module interface * WIP trying to import module from settings * Add EnableModule.ps1 * spellcheck * spellcheck again * Installer. Add DisableModule.ps1 * Fix styling * Give the user some output from installing * Prettify the Settings controls * Add button to check PowerShell 7's version * Fix Settings Assets paths * Fix PowerShell 7 output * Make module enable and disable scripts give better information * Fix spellcheck * Fix image files and placeholders * Don't remove CmdNotFound on upgrade and don't fail on uninstall of CmdNotFound * Consistent install module scripts location on debug and installed * installer: Avoid messageboxes and hide powershell on uninstalling CmdNotFound * Fix psd1 file resolution when installed * Fix spellcheck * Add telemetry events * Fix gpo files * If GPO is set, enable/disable module on PT start depending on gpo value * Cleanup module interface * Cleanup settings code * If GPO is set, disable Settings page logic * Adding icons * Update settings UI and strings * Add telemetry for suggestions and feedbacks * Fix sln file * Fix build * minor fixes * Updating icon * Remove global.json * Remove unused PowerShell dependency * Don't use preview version of Automation and fix NOTICE * Fix signing * Fix NOTICE.md * Fix version checking for getfilesiginforedist.dll * Fix spellchecker * Fix README.md * Fix false positives section in expect.txt * Add logs to module interface --------- Co-authored-by: Stefan Markovic <stefan@janeasystems.com> Co-authored-by: Jaime Bernardo <jaime@janeasystems.com> Co-authored-by: Niels Laute <niels.laute@live.nl>
2024-01-03 07:43:42 -08:00
{
string outputLog = string.Empty;
try
{
var startInfo = new ProcessStartInfo()
{
[CmdNotFound]Improve installation workflow (#30727) * [CmdNotFound]Improve installation workflow * Fix typo * Fix XAML styling * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Don't create window for checking requirements * Hide install/uninstall buttons for CmdNotFound module * Also install winget before Powershell 7 * Better detect processor architecture * Fix spellcheck * [CMDNotFound] UX improvements (#30740) * UI improvements * Updated label * Update CmdNotFoundPage.xaml * Update CmdNotFoundPage.xaml * Update CmdNotFoundPage.xaml * Better version detection * Add some logging * Add missing package install that's a prerequisite for winget * Remove unused AllExperiments include * Fix Logger library include * Update PATH Environment variable after installing PS * Fix OOBE UI spacing * Use Invoke-WebRequest to get the deps and then install them from local path * Spellcheck * TEMP -> TMP * User path is supposed to come after machine path --------- Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> Co-authored-by: Niels Laute <niels.laute@live.nl> Co-authored-by: Stefan Markovic <stefan@janeasystems.com>
2024-01-05 09:26:49 +00:00
FileName = powershellExecutable,
Introduce Command Not Found module (#26319) * Introduce Command Not Found module * rewrite module to depend on WinGet PowerShell module * address Dongbo's feedback * try and implement settings UI * fix SUI build; try and store PowerShell object * add and use object pool * apply Dongbo's feedback * add warm up; implement IPooledObjectPolicy * Add module interface * WIP trying to import module from settings * Add EnableModule.ps1 * spellcheck * spellcheck again * Installer. Add DisableModule.ps1 * Fix styling * Give the user some output from installing * Prettify the Settings controls * Add button to check PowerShell 7's version * Fix Settings Assets paths * Fix PowerShell 7 output * Make module enable and disable scripts give better information * Fix spellcheck * Fix image files and placeholders * Don't remove CmdNotFound on upgrade and don't fail on uninstall of CmdNotFound * Consistent install module scripts location on debug and installed * installer: Avoid messageboxes and hide powershell on uninstalling CmdNotFound * Fix psd1 file resolution when installed * Fix spellcheck * Add telemetry events * Fix gpo files * If GPO is set, enable/disable module on PT start depending on gpo value * Cleanup module interface * Cleanup settings code * If GPO is set, disable Settings page logic * Adding icons * Update settings UI and strings * Add telemetry for suggestions and feedbacks * Fix sln file * Fix build * minor fixes * Updating icon * Remove global.json * Remove unused PowerShell dependency * Don't use preview version of Automation and fix NOTICE * Fix signing * Fix NOTICE.md * Fix version checking for getfilesiginforedist.dll * Fix spellchecker * Fix README.md * Fix false positives section in expect.txt * Add logs to module interface --------- Co-authored-by: Stefan Markovic <stefan@janeasystems.com> Co-authored-by: Jaime Bernardo <jaime@janeasystems.com> Co-authored-by: Niels Laute <niels.laute@live.nl>
2024-01-03 07:43:42 -08:00
Arguments = powershellArguments,
[CmdNotFound]Improve installation workflow (#30727) * [CmdNotFound]Improve installation workflow * Fix typo * Fix XAML styling * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Don't create window for checking requirements * Hide install/uninstall buttons for CmdNotFound module * Also install winget before Powershell 7 * Better detect processor architecture * Fix spellcheck * [CMDNotFound] UX improvements (#30740) * UI improvements * Updated label * Update CmdNotFoundPage.xaml * Update CmdNotFoundPage.xaml * Update CmdNotFoundPage.xaml * Better version detection * Add some logging * Add missing package install that's a prerequisite for winget * Remove unused AllExperiments include * Fix Logger library include * Update PATH Environment variable after installing PS * Fix OOBE UI spacing * Use Invoke-WebRequest to get the deps and then install them from local path * Spellcheck * TEMP -> TMP * User path is supposed to come after machine path --------- Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> Co-authored-by: Niels Laute <niels.laute@live.nl> Co-authored-by: Stefan Markovic <stefan@janeasystems.com>
2024-01-05 09:26:49 +00:00
CreateNoWindow = hidePowerShellWindow,
Introduce Command Not Found module (#26319) * Introduce Command Not Found module * rewrite module to depend on WinGet PowerShell module * address Dongbo's feedback * try and implement settings UI * fix SUI build; try and store PowerShell object * add and use object pool * apply Dongbo's feedback * add warm up; implement IPooledObjectPolicy * Add module interface * WIP trying to import module from settings * Add EnableModule.ps1 * spellcheck * spellcheck again * Installer. Add DisableModule.ps1 * Fix styling * Give the user some output from installing * Prettify the Settings controls * Add button to check PowerShell 7's version * Fix Settings Assets paths * Fix PowerShell 7 output * Make module enable and disable scripts give better information * Fix spellcheck * Fix image files and placeholders * Don't remove CmdNotFound on upgrade and don't fail on uninstall of CmdNotFound * Consistent install module scripts location on debug and installed * installer: Avoid messageboxes and hide powershell on uninstalling CmdNotFound * Fix psd1 file resolution when installed * Fix spellcheck * Add telemetry events * Fix gpo files * If GPO is set, enable/disable module on PT start depending on gpo value * Cleanup module interface * Cleanup settings code * If GPO is set, disable Settings page logic * Adding icons * Update settings UI and strings * Add telemetry for suggestions and feedbacks * Fix sln file * Fix build * minor fixes * Updating icon * Remove global.json * Remove unused PowerShell dependency * Don't use preview version of Automation and fix NOTICE * Fix signing * Fix NOTICE.md * Fix version checking for getfilesiginforedist.dll * Fix spellchecker * Fix README.md * Fix false positives section in expect.txt * Add logs to module interface --------- Co-authored-by: Stefan Markovic <stefan@janeasystems.com> Co-authored-by: Jaime Bernardo <jaime@janeasystems.com> Co-authored-by: Niels Laute <niels.laute@live.nl>
2024-01-03 07:43:42 -08:00
UseShellExecute = false,
RedirectStandardOutput = true,
};
startInfo.EnvironmentVariables["NO_COLOR"] = "1";
var process = Process.Start(startInfo);
while (!process.StandardOutput.EndOfStream)
{
outputLog += process.StandardOutput.ReadLine() + "\r\n"; // Weirdly, PowerShell 7 won't give us new lines.
}
}
catch (Exception ex)
{
outputLog = ex.ToString();
}
CommandOutputLog = outputLog;
[CmdNotFound]Improve installation workflow (#30727) * [CmdNotFound]Improve installation workflow * Fix typo * Fix XAML styling * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Don't create window for checking requirements * Hide install/uninstall buttons for CmdNotFound module * Also install winget before Powershell 7 * Better detect processor architecture * Fix spellcheck * [CMDNotFound] UX improvements (#30740) * UI improvements * Updated label * Update CmdNotFoundPage.xaml * Update CmdNotFoundPage.xaml * Update CmdNotFoundPage.xaml * Better version detection * Add some logging * Add missing package install that's a prerequisite for winget * Remove unused AllExperiments include * Fix Logger library include * Update PATH Environment variable after installing PS * Fix OOBE UI spacing * Use Invoke-WebRequest to get the deps and then install them from local path * Spellcheck * TEMP -> TMP * User path is supposed to come after machine path --------- Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> Co-authored-by: Niels Laute <niels.laute@live.nl> Co-authored-by: Stefan Markovic <stefan@janeasystems.com>
2024-01-05 09:26:49 +00:00
return outputLog;
Introduce Command Not Found module (#26319) * Introduce Command Not Found module * rewrite module to depend on WinGet PowerShell module * address Dongbo's feedback * try and implement settings UI * fix SUI build; try and store PowerShell object * add and use object pool * apply Dongbo's feedback * add warm up; implement IPooledObjectPolicy * Add module interface * WIP trying to import module from settings * Add EnableModule.ps1 * spellcheck * spellcheck again * Installer. Add DisableModule.ps1 * Fix styling * Give the user some output from installing * Prettify the Settings controls * Add button to check PowerShell 7's version * Fix Settings Assets paths * Fix PowerShell 7 output * Make module enable and disable scripts give better information * Fix spellcheck * Fix image files and placeholders * Don't remove CmdNotFound on upgrade and don't fail on uninstall of CmdNotFound * Consistent install module scripts location on debug and installed * installer: Avoid messageboxes and hide powershell on uninstalling CmdNotFound * Fix psd1 file resolution when installed * Fix spellcheck * Add telemetry events * Fix gpo files * If GPO is set, enable/disable module on PT start depending on gpo value * Cleanup module interface * Cleanup settings code * If GPO is set, disable Settings page logic * Adding icons * Update settings UI and strings * Add telemetry for suggestions and feedbacks * Fix sln file * Fix build * minor fixes * Updating icon * Remove global.json * Remove unused PowerShell dependency * Don't use preview version of Automation and fix NOTICE * Fix signing * Fix NOTICE.md * Fix version checking for getfilesiginforedist.dll * Fix spellchecker * Fix README.md * Fix false positives section in expect.txt * Add logs to module interface --------- Co-authored-by: Stefan Markovic <stefan@janeasystems.com> Co-authored-by: Jaime Bernardo <jaime@janeasystems.com> Co-authored-by: Niels Laute <niels.laute@live.nl>
2024-01-03 07:43:42 -08:00
}
[CmdNotFound]Improve installation workflow (#30727) * [CmdNotFound]Improve installation workflow * Fix typo * Fix XAML styling * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Don't create window for checking requirements * Hide install/uninstall buttons for CmdNotFound module * Also install winget before Powershell 7 * Better detect processor architecture * Fix spellcheck * [CMDNotFound] UX improvements (#30740) * UI improvements * Updated label * Update CmdNotFoundPage.xaml * Update CmdNotFoundPage.xaml * Update CmdNotFoundPage.xaml * Better version detection * Add some logging * Add missing package install that's a prerequisite for winget * Remove unused AllExperiments include * Fix Logger library include * Update PATH Environment variable after installing PS * Fix OOBE UI spacing * Use Invoke-WebRequest to get the deps and then install them from local path * Spellcheck * TEMP -> TMP * User path is supposed to come after machine path --------- Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> Co-authored-by: Niels Laute <niels.laute@live.nl> Co-authored-by: Stefan Markovic <stefan@janeasystems.com>
2024-01-05 09:26:49 +00:00
public void CheckCommandNotFoundRequirements()
Introduce Command Not Found module (#26319) * Introduce Command Not Found module * rewrite module to depend on WinGet PowerShell module * address Dongbo's feedback * try and implement settings UI * fix SUI build; try and store PowerShell object * add and use object pool * apply Dongbo's feedback * add warm up; implement IPooledObjectPolicy * Add module interface * WIP trying to import module from settings * Add EnableModule.ps1 * spellcheck * spellcheck again * Installer. Add DisableModule.ps1 * Fix styling * Give the user some output from installing * Prettify the Settings controls * Add button to check PowerShell 7's version * Fix Settings Assets paths * Fix PowerShell 7 output * Make module enable and disable scripts give better information * Fix spellcheck * Fix image files and placeholders * Don't remove CmdNotFound on upgrade and don't fail on uninstall of CmdNotFound * Consistent install module scripts location on debug and installed * installer: Avoid messageboxes and hide powershell on uninstalling CmdNotFound * Fix psd1 file resolution when installed * Fix spellcheck * Add telemetry events * Fix gpo files * If GPO is set, enable/disable module on PT start depending on gpo value * Cleanup module interface * Cleanup settings code * If GPO is set, disable Settings page logic * Adding icons * Update settings UI and strings * Add telemetry for suggestions and feedbacks * Fix sln file * Fix build * minor fixes * Updating icon * Remove global.json * Remove unused PowerShell dependency * Don't use preview version of Automation and fix NOTICE * Fix signing * Fix NOTICE.md * Fix version checking for getfilesiginforedist.dll * Fix spellchecker * Fix README.md * Fix false positives section in expect.txt * Add logs to module interface --------- Co-authored-by: Stefan Markovic <stefan@janeasystems.com> Co-authored-by: Jaime Bernardo <jaime@janeasystems.com> Co-authored-by: Niels Laute <niels.laute@live.nl>
2024-01-03 07:43:42 -08:00
{
[CmdNotFound]Improve installation workflow (#30727) * [CmdNotFound]Improve installation workflow * Fix typo * Fix XAML styling * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Don't create window for checking requirements * Hide install/uninstall buttons for CmdNotFound module * Also install winget before Powershell 7 * Better detect processor architecture * Fix spellcheck * [CMDNotFound] UX improvements (#30740) * UI improvements * Updated label * Update CmdNotFoundPage.xaml * Update CmdNotFoundPage.xaml * Update CmdNotFoundPage.xaml * Better version detection * Add some logging * Add missing package install that's a prerequisite for winget * Remove unused AllExperiments include * Fix Logger library include * Update PATH Environment variable after installing PS * Fix OOBE UI spacing * Use Invoke-WebRequest to get the deps and then install them from local path * Spellcheck * TEMP -> TMP * User path is supposed to come after machine path --------- Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> Co-authored-by: Niels Laute <niels.laute@live.nl> Co-authored-by: Stefan Markovic <stefan@janeasystems.com>
2024-01-05 09:26:49 +00:00
var ps1File = AssemblyDirectory + "\\Assets\\Settings\\Scripts\\CheckCmdNotFoundRequirements.ps1";
var arguments = $"-NoProfile -NonInteractive -ExecutionPolicy Unrestricted -File \"{ps1File}\"";
var result = RunPowerShellScript("pwsh.exe", arguments, true);
if (result.Contains("PowerShell 7.4 or greater detected."))
{
IsPowerShell7Detected = true;
}
else if (result.Contains("PowerShell 7.4 or greater not detected."))
{
IsPowerShell7Detected = false;
}
else if (result.Contains("pwsh.exe"))
{
// Likely an error saying there was an error starting pwsh.exe, so we can assume Powershell 7 was not detected.
CommandOutputLog += "PowerShell 7.4 or greater not detected. Installation instructions can be found on https://learn.microsoft.com/powershell/scripting/install/installing-powershell-on-windows \r\n";
IsPowerShell7Detected = false;
}
if (result.Contains("WinGet Client module detected."))
{
IsWinGetClientModuleDetected = true;
}
else if (result.Contains("WinGet Client module not detected."))
{
IsWinGetClientModuleDetected = false;
}
if (result.Contains("Command Not Found module is registered in the profile file."))
{
IsCommandNotFoundModuleInstalled = true;
}
else if (result.Contains("Command Not Found module is not registered in the profile file."))
{
IsCommandNotFoundModuleInstalled = false;
}
Logger.LogInfo(result);
}
public void InstallPowerShell7()
{
var ps1File = AssemblyDirectory + "\\Assets\\Settings\\Scripts\\InstallPowerShell7.ps1";
var arguments = $"-NoProfile -ExecutionPolicy Unrestricted -File \"{ps1File}\"";
var result = RunPowerShellScript("powershell.exe", arguments);
if (result.Contains("Powershell 7 successfully installed."))
{
IsPowerShell7Detected = true;
}
Logger.LogInfo(result);
// Update PATH environment variable to get pwsh.exe on further calls.
Environment.SetEnvironmentVariable("PATH", (Environment.GetEnvironmentVariable("PATH", EnvironmentVariableTarget.Machine) ?? string.Empty) + ";" + (Environment.GetEnvironmentVariable("PATH", EnvironmentVariableTarget.User) ?? string.Empty), EnvironmentVariableTarget.Process);
}
public void InstallWinGetClientModule()
{
var ps1File = AssemblyDirectory + "\\Assets\\Settings\\Scripts\\InstallWinGetClientModule.ps1";
var arguments = $"-NoProfile -ExecutionPolicy Unrestricted -File \"{ps1File}\"";
var result = RunPowerShellScript("pwsh.exe", arguments);
if (result.Contains("WinGet Client module detected."))
{
IsWinGetClientModuleDetected = true;
}
else if (result.Contains("WinGet Client module not detected."))
{
IsWinGetClientModuleDetected = false;
}
Logger.LogInfo(result);
Introduce Command Not Found module (#26319) * Introduce Command Not Found module * rewrite module to depend on WinGet PowerShell module * address Dongbo's feedback * try and implement settings UI * fix SUI build; try and store PowerShell object * add and use object pool * apply Dongbo's feedback * add warm up; implement IPooledObjectPolicy * Add module interface * WIP trying to import module from settings * Add EnableModule.ps1 * spellcheck * spellcheck again * Installer. Add DisableModule.ps1 * Fix styling * Give the user some output from installing * Prettify the Settings controls * Add button to check PowerShell 7's version * Fix Settings Assets paths * Fix PowerShell 7 output * Make module enable and disable scripts give better information * Fix spellcheck * Fix image files and placeholders * Don't remove CmdNotFound on upgrade and don't fail on uninstall of CmdNotFound * Consistent install module scripts location on debug and installed * installer: Avoid messageboxes and hide powershell on uninstalling CmdNotFound * Fix psd1 file resolution when installed * Fix spellcheck * Add telemetry events * Fix gpo files * If GPO is set, enable/disable module on PT start depending on gpo value * Cleanup module interface * Cleanup settings code * If GPO is set, disable Settings page logic * Adding icons * Update settings UI and strings * Add telemetry for suggestions and feedbacks * Fix sln file * Fix build * minor fixes * Updating icon * Remove global.json * Remove unused PowerShell dependency * Don't use preview version of Automation and fix NOTICE * Fix signing * Fix NOTICE.md * Fix version checking for getfilesiginforedist.dll * Fix spellchecker * Fix README.md * Fix false positives section in expect.txt * Add logs to module interface --------- Co-authored-by: Stefan Markovic <stefan@janeasystems.com> Co-authored-by: Jaime Bernardo <jaime@janeasystems.com> Co-authored-by: Niels Laute <niels.laute@live.nl>
2024-01-03 07:43:42 -08:00
}
public void InstallModule()
{
var ps1File = AssemblyDirectory + "\\Assets\\Settings\\Scripts\\EnableModule.ps1";
var arguments = $"-NoProfile -ExecutionPolicy Unrestricted -File \"{ps1File}\" -scriptPath \"{AssemblyDirectory}\\..\"";
[CmdNotFound]Improve installation workflow (#30727) * [CmdNotFound]Improve installation workflow * Fix typo * Fix XAML styling * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Don't create window for checking requirements * Hide install/uninstall buttons for CmdNotFound module * Also install winget before Powershell 7 * Better detect processor architecture * Fix spellcheck * [CMDNotFound] UX improvements (#30740) * UI improvements * Updated label * Update CmdNotFoundPage.xaml * Update CmdNotFoundPage.xaml * Update CmdNotFoundPage.xaml * Better version detection * Add some logging * Add missing package install that's a prerequisite for winget * Remove unused AllExperiments include * Fix Logger library include * Update PATH Environment variable after installing PS * Fix OOBE UI spacing * Use Invoke-WebRequest to get the deps and then install them from local path * Spellcheck * TEMP -> TMP * User path is supposed to come after machine path --------- Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> Co-authored-by: Niels Laute <niels.laute@live.nl> Co-authored-by: Stefan Markovic <stefan@janeasystems.com>
2024-01-05 09:26:49 +00:00
var result = RunPowerShellScript("pwsh.exe", arguments);
if (result.Contains("Module is already registered in the profile file.") || result.Contains("Module was successfully registered in the profile file."))
{
IsCommandNotFoundModuleInstalled = true;
PowerToysTelemetry.Log.WriteEvent(new CmdNotFoundInstallEvent());
}
Logger.LogInfo(result);
Introduce Command Not Found module (#26319) * Introduce Command Not Found module * rewrite module to depend on WinGet PowerShell module * address Dongbo's feedback * try and implement settings UI * fix SUI build; try and store PowerShell object * add and use object pool * apply Dongbo's feedback * add warm up; implement IPooledObjectPolicy * Add module interface * WIP trying to import module from settings * Add EnableModule.ps1 * spellcheck * spellcheck again * Installer. Add DisableModule.ps1 * Fix styling * Give the user some output from installing * Prettify the Settings controls * Add button to check PowerShell 7's version * Fix Settings Assets paths * Fix PowerShell 7 output * Make module enable and disable scripts give better information * Fix spellcheck * Fix image files and placeholders * Don't remove CmdNotFound on upgrade and don't fail on uninstall of CmdNotFound * Consistent install module scripts location on debug and installed * installer: Avoid messageboxes and hide powershell on uninstalling CmdNotFound * Fix psd1 file resolution when installed * Fix spellcheck * Add telemetry events * Fix gpo files * If GPO is set, enable/disable module on PT start depending on gpo value * Cleanup module interface * Cleanup settings code * If GPO is set, disable Settings page logic * Adding icons * Update settings UI and strings * Add telemetry for suggestions and feedbacks * Fix sln file * Fix build * minor fixes * Updating icon * Remove global.json * Remove unused PowerShell dependency * Don't use preview version of Automation and fix NOTICE * Fix signing * Fix NOTICE.md * Fix version checking for getfilesiginforedist.dll * Fix spellchecker * Fix README.md * Fix false positives section in expect.txt * Add logs to module interface --------- Co-authored-by: Stefan Markovic <stefan@janeasystems.com> Co-authored-by: Jaime Bernardo <jaime@janeasystems.com> Co-authored-by: Niels Laute <niels.laute@live.nl>
2024-01-03 07:43:42 -08:00
}
public void UninstallModule()
{
var ps1File = AssemblyDirectory + "\\Assets\\Settings\\Scripts\\DisableModule.ps1";
var arguments = $"-NoProfile -ExecutionPolicy Unrestricted -File \"{ps1File}\"";
[CmdNotFound]Improve installation workflow (#30727) * [CmdNotFound]Improve installation workflow * Fix typo * Fix XAML styling * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Don't create window for checking requirements * Hide install/uninstall buttons for CmdNotFound module * Also install winget before Powershell 7 * Better detect processor architecture * Fix spellcheck * [CMDNotFound] UX improvements (#30740) * UI improvements * Updated label * Update CmdNotFoundPage.xaml * Update CmdNotFoundPage.xaml * Update CmdNotFoundPage.xaml * Better version detection * Add some logging * Add missing package install that's a prerequisite for winget * Remove unused AllExperiments include * Fix Logger library include * Update PATH Environment variable after installing PS * Fix OOBE UI spacing * Use Invoke-WebRequest to get the deps and then install them from local path * Spellcheck * TEMP -> TMP * User path is supposed to come after machine path --------- Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> Co-authored-by: Niels Laute <niels.laute@live.nl> Co-authored-by: Stefan Markovic <stefan@janeasystems.com>
2024-01-05 09:26:49 +00:00
var result = RunPowerShellScript("pwsh.exe", arguments);
if (result.Contains("Removed the Command Not Found reference from the profile file.") || result.Contains("No instance of Command Not Found was found in the profile file."))
{
IsCommandNotFoundModuleInstalled = false;
PowerToysTelemetry.Log.WriteEvent(new CmdNotFoundUninstallEvent());
}
Logger.LogInfo(result);
Introduce Command Not Found module (#26319) * Introduce Command Not Found module * rewrite module to depend on WinGet PowerShell module * address Dongbo's feedback * try and implement settings UI * fix SUI build; try and store PowerShell object * add and use object pool * apply Dongbo's feedback * add warm up; implement IPooledObjectPolicy * Add module interface * WIP trying to import module from settings * Add EnableModule.ps1 * spellcheck * spellcheck again * Installer. Add DisableModule.ps1 * Fix styling * Give the user some output from installing * Prettify the Settings controls * Add button to check PowerShell 7's version * Fix Settings Assets paths * Fix PowerShell 7 output * Make module enable and disable scripts give better information * Fix spellcheck * Fix image files and placeholders * Don't remove CmdNotFound on upgrade and don't fail on uninstall of CmdNotFound * Consistent install module scripts location on debug and installed * installer: Avoid messageboxes and hide powershell on uninstalling CmdNotFound * Fix psd1 file resolution when installed * Fix spellcheck * Add telemetry events * Fix gpo files * If GPO is set, enable/disable module on PT start depending on gpo value * Cleanup module interface * Cleanup settings code * If GPO is set, disable Settings page logic * Adding icons * Update settings UI and strings * Add telemetry for suggestions and feedbacks * Fix sln file * Fix build * minor fixes * Updating icon * Remove global.json * Remove unused PowerShell dependency * Don't use preview version of Automation and fix NOTICE * Fix signing * Fix NOTICE.md * Fix version checking for getfilesiginforedist.dll * Fix spellchecker * Fix README.md * Fix false positives section in expect.txt * Add logs to module interface --------- Co-authored-by: Stefan Markovic <stefan@janeasystems.com> Co-authored-by: Jaime Bernardo <jaime@janeasystems.com> Co-authored-by: Niels Laute <niels.laute@live.nl>
2024-01-03 07:43:42 -08:00
}
[CmdNotFound]Improve installation workflow (#30727) * [CmdNotFound]Improve installation workflow * Fix typo * Fix XAML styling * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Update src/settings-ui/Settings.UI/SettingsXAML/Views/CmdNotFoundPage.xaml Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> * Don't create window for checking requirements * Hide install/uninstall buttons for CmdNotFound module * Also install winget before Powershell 7 * Better detect processor architecture * Fix spellcheck * [CMDNotFound] UX improvements (#30740) * UI improvements * Updated label * Update CmdNotFoundPage.xaml * Update CmdNotFoundPage.xaml * Update CmdNotFoundPage.xaml * Better version detection * Add some logging * Add missing package install that's a prerequisite for winget * Remove unused AllExperiments include * Fix Logger library include * Update PATH Environment variable after installing PS * Fix OOBE UI spacing * Use Invoke-WebRequest to get the deps and then install them from local path * Spellcheck * TEMP -> TMP * User path is supposed to come after machine path --------- Co-authored-by: Davide Giacometti <davide.giacometti@outlook.it> Co-authored-by: Niels Laute <niels.laute@live.nl> Co-authored-by: Stefan Markovic <stefan@janeasystems.com>
2024-01-05 09:26:49 +00:00
}
Introduce Command Not Found module (#26319) * Introduce Command Not Found module * rewrite module to depend on WinGet PowerShell module * address Dongbo's feedback * try and implement settings UI * fix SUI build; try and store PowerShell object * add and use object pool * apply Dongbo's feedback * add warm up; implement IPooledObjectPolicy * Add module interface * WIP trying to import module from settings * Add EnableModule.ps1 * spellcheck * spellcheck again * Installer. Add DisableModule.ps1 * Fix styling * Give the user some output from installing * Prettify the Settings controls * Add button to check PowerShell 7's version * Fix Settings Assets paths * Fix PowerShell 7 output * Make module enable and disable scripts give better information * Fix spellcheck * Fix image files and placeholders * Don't remove CmdNotFound on upgrade and don't fail on uninstall of CmdNotFound * Consistent install module scripts location on debug and installed * installer: Avoid messageboxes and hide powershell on uninstalling CmdNotFound * Fix psd1 file resolution when installed * Fix spellcheck * Add telemetry events * Fix gpo files * If GPO is set, enable/disable module on PT start depending on gpo value * Cleanup module interface * Cleanup settings code * If GPO is set, disable Settings page logic * Adding icons * Update settings UI and strings * Add telemetry for suggestions and feedbacks * Fix sln file * Fix build * minor fixes * Updating icon * Remove global.json * Remove unused PowerShell dependency * Don't use preview version of Automation and fix NOTICE * Fix signing * Fix NOTICE.md * Fix version checking for getfilesiginforedist.dll * Fix spellchecker * Fix README.md * Fix false positives section in expect.txt * Add logs to module interface --------- Co-authored-by: Stefan Markovic <stefan@janeasystems.com> Co-authored-by: Jaime Bernardo <jaime@janeasystems.com> Co-authored-by: Niels Laute <niels.laute@live.nl>
2024-01-03 07:43:42 -08:00
}