mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 03:37:59 +01:00
[Installer]Use custom action to copy DSC files on user install (#32799)
* Better fix for installation issues when My Documents on network drive * Fix spellcheck * Improved wxs comment * Created DSCModule folder in install folder; removed DSC modules from resources * Added back newline
This commit is contained in:
3
.github/actions/spell-check/patterns.txt
vendored
3
.github/actions/spell-check/patterns.txt
vendored
@@ -40,6 +40,9 @@
|
|||||||
# tabs in c#
|
# tabs in c#
|
||||||
\$"\\t
|
\$"\\t
|
||||||
|
|
||||||
|
# Hexadecimal character pattern in code
|
||||||
|
\\x[0-9a-fA-F][0-9a-fA-F]
|
||||||
|
|
||||||
# windows line breaks in strings
|
# windows line breaks in strings
|
||||||
\\r\\n
|
\\r\\n
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
<DirectoryRef Id="INSTALLFOLDER" FileSource="$(var.BinDir)">
|
<DirectoryRef Id="INSTALLFOLDER" FileSource="$(var.BinDir)">
|
||||||
<Component Id="powertoys_per_machine_comp" Win64="yes">
|
<Component Id="powertoys_per_machine_comp" Win64="yes">
|
||||||
<RegistryKey Root="$(var.RegistryScope)" Key="Software\Classes\powertoys">
|
<RegistryKey Root="$(var.RegistryScope)" Key="Software\Classes\powertoys">
|
||||||
<RegistryValue Type="string" Name="InstallScope" Value="$(var.InstallScope)" />
|
<RegistryValue Type="string" Name="InstallScope" Value="$(var.InstallScope)" />
|
||||||
</RegistryKey>
|
</RegistryKey>
|
||||||
</Component>
|
</Component>
|
||||||
<Component Id="powertoys_toast_clsid" Win64="yes">
|
<Component Id="powertoys_toast_clsid" Win64="yes">
|
||||||
@@ -46,34 +46,19 @@
|
|||||||
</Component>
|
</Component>
|
||||||
</DirectoryRef>
|
</DirectoryRef>
|
||||||
|
|
||||||
<?if $(var.PerUser) = "true" ?>
|
<DirectoryRef Id="DSCModulesReferenceFolder">
|
||||||
<DirectoryRef Id="PersonalFolder">
|
<Component Id="PowerToysDSCReference" Win64="yes" Guid="40869ACB-0BEB-4911-AE41-5E73BC1586A9">
|
||||||
<Directory Id="WindowsPowerShellFolder" Name="PowerShell">
|
<RegistryKey Root="$(var.RegistryScope)" Key="Software\Classes\powertoys\components">
|
||||||
<Directory Id="PowerShellModulesFolder" Name="Modules">
|
<RegistryValue Type="string" Name="DSCModulesReference" Value="" KeyPath="yes"/>
|
||||||
<Directory Id="PowerToysDscFolder" Name="Microsoft.PowerToys.Configure">
|
</RegistryKey>
|
||||||
<Directory Id="PowerToysDscVerFolder" Name="$(var.Version)">
|
<File Source="$(var.RepoDir)\src\dsc\Microsoft.PowerToys.Configure\Generated\Microsoft.PowerToys.Configure\$(var.Version)\Microsoft.PowerToys.Configure.psd1" Id="PTConfReference.psd1" />
|
||||||
<Component Id="PowerToysDSC" Win64="yes" Guid="4A033E3B-6590-43FD-8FBD-27F9DF557F7F">
|
<File Source="$(var.RepoDir)\src\dsc\Microsoft.PowerToys.Configure\Generated\Microsoft.PowerToys.Configure\$(var.Version)\Microsoft.PowerToys.Configure.psm1" Id="PTConfReference.psm1" />
|
||||||
<RegistryValue Root="HKCU"
|
</Component>
|
||||||
Key="Software\[Manufacturer]\[ProductName]"
|
|
||||||
Name="DSCInstalled"
|
|
||||||
Type="integer"
|
|
||||||
Value="1"
|
|
||||||
KeyPath="yes"/>
|
|
||||||
<!-- Don't fail installation because of DSC. Files are marked as not vital. -->
|
|
||||||
<File Vital="no" Source="$(var.RepoDir)\src\dsc\Microsoft.PowerToys.Configure\Generated\Microsoft.PowerToys.Configure\$(var.Version)\Microsoft.PowerToys.Configure.psd1" Id="PTConf.psd1" />
|
|
||||||
<File Vital="no" Source="$(var.RepoDir)\src\dsc\Microsoft.PowerToys.Configure\Generated\Microsoft.PowerToys.Configure\$(var.Version)\Microsoft.PowerToys.Configure.psm1" Id="PTConf.psm1" />
|
|
||||||
<RemoveFolder Id="RemoveThisFolder" On="uninstall" />
|
|
||||||
<RemoveFolder Id="RemovePowerToysDscVerFolder" Directory="PowerToysDscVerFolder" On="uninstall" />
|
|
||||||
<RemoveFolder Id="RemovePowerToysDscFolder" Directory="PowerToysDscFolder" On="uninstall" />
|
|
||||||
<RemoveFolder Id="RemovePowerShellModulesFolder" Directory="PowerShellModulesFolder" On="uninstall" />
|
|
||||||
<RemoveFolder Id="RemoveWindowsPowerShellFolder" Directory="WindowsPowerShellFolder" On="uninstall" />
|
|
||||||
</Component>
|
|
||||||
</Directory>
|
|
||||||
</Directory>
|
|
||||||
</Directory>
|
|
||||||
</Directory>
|
|
||||||
</DirectoryRef>
|
</DirectoryRef>
|
||||||
<?else?>
|
|
||||||
|
<?if $(var.PerUser) = "true" ?>
|
||||||
|
<!-- DSC module files for PerUser handled in InstallDSCModule custom action. -->
|
||||||
|
<?else?>
|
||||||
<DirectoryRef Id="ProgramFiles64Folder">
|
<DirectoryRef Id="ProgramFiles64Folder">
|
||||||
<Directory Id="WindowsPowerShellFolder" Name="WindowsPowerShell">
|
<Directory Id="WindowsPowerShellFolder" Name="WindowsPowerShell">
|
||||||
<Directory Id="PowerShellModulesFolder" Name="Modules">
|
<Directory Id="PowerShellModulesFolder" Name="Modules">
|
||||||
@@ -89,7 +74,7 @@
|
|||||||
</Directory>
|
</Directory>
|
||||||
</Directory>
|
</Directory>
|
||||||
</DirectoryRef>
|
</DirectoryRef>
|
||||||
<?endif?>
|
<?endif?>
|
||||||
|
|
||||||
<DirectoryRef Id="ApplicationProgramsFolder">
|
<DirectoryRef Id="ApplicationProgramsFolder">
|
||||||
<Component Id="PowerToysStartMenuShortcut" >
|
<Component Id="PowerToysStartMenuShortcut" >
|
||||||
@@ -130,23 +115,27 @@
|
|||||||
</Fragment>
|
</Fragment>
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<ComponentGroup Id="CoreComponents">
|
<ComponentGroup Id="CoreComponents">
|
||||||
<Component Id="RemoveCoreFolder" Guid="9330BD69-2D12-4D98-B0C7-66C99564D619" Directory="INSTALLFOLDER" >
|
<Component Id="RemoveCoreFolder" Guid="9330BD69-2D12-4D98-B0C7-66C99564D619" Directory="INSTALLFOLDER" >
|
||||||
<RegistryKey Root="$(var.RegistryScope)" Key="Software\Classes\powertoys\components">
|
<RegistryKey Root="$(var.RegistryScope)" Key="Software\Classes\powertoys\components">
|
||||||
<RegistryValue Type="string" Name="RemoveCoreFolder" Value="" KeyPath="yes"/>
|
<RegistryValue Type="string" Name="RemoveCoreFolder" Value="" KeyPath="yes"/>
|
||||||
</RegistryKey>
|
</RegistryKey>
|
||||||
<RemoveFolder Id="RemoveBaseApplicationsAssetsFolder" Directory="BaseApplicationsAssetsFolder" On="uninstall"/>
|
<RemoveFolder Id="RemoveBaseApplicationsAssetsFolder" Directory="BaseApplicationsAssetsFolder" On="uninstall"/>
|
||||||
<RemoveFolder Id="RemoveWinUI3AppsInstallFolder" Directory="WinUI3AppsInstallFolder" On="uninstall"/>
|
<RemoveFolder Id="RemoveDSCModulesReferenceFolder" Directory="DSCModulesReferenceFolder" On="uninstall"/>
|
||||||
<RemoveFolder Id="RemoveWinUI3AppsAssetsFolder" Directory="WinUI3AppsAssetsFolder" On="uninstall"/>
|
<RemoveFolder Id="RemoveWinUI3AppsInstallFolder" Directory="WinUI3AppsInstallFolder" On="uninstall"/>
|
||||||
<RemoveFolder Id="RemoveINSTALLFOLDER" Directory="INSTALLFOLDER" On="uninstall"/>
|
<RemoveFolder Id="RemoveWinUI3AppsAssetsFolder" Directory="WinUI3AppsAssetsFolder" On="uninstall"/>
|
||||||
</Component>
|
<RemoveFolder Id="RemoveINSTALLFOLDER" Directory="INSTALLFOLDER" On="uninstall"/>
|
||||||
<ComponentRef Id="powertoys_exe" />
|
</Component>
|
||||||
<ComponentRef Id="PowerToysStartMenuShortcut"/>
|
<ComponentRef Id="powertoys_exe" />
|
||||||
<ComponentRef Id="powertoys_per_machine_comp" />
|
<ComponentRef Id="PowerToysStartMenuShortcut"/>
|
||||||
<ComponentRef Id="powertoys_toast_clsid" />
|
<ComponentRef Id="powertoys_per_machine_comp" />
|
||||||
<ComponentRef Id="License_rtf" />
|
<ComponentRef Id="powertoys_toast_clsid" />
|
||||||
<ComponentRef Id="Notice_md" />
|
<ComponentRef Id="License_rtf" />
|
||||||
<ComponentRef Id="DesktopShortcut" />
|
<ComponentRef Id="Notice_md" />
|
||||||
<ComponentRef Id="PowerToysDSC" />
|
<ComponentRef Id="DesktopShortcut" />
|
||||||
|
<ComponentRef Id="PowerToysDSCReference" />
|
||||||
|
<?if $(var.PerUser) = "false" ?>
|
||||||
|
<ComponentRef Id="PowerToysDSC" />
|
||||||
|
<?endif?>
|
||||||
</ComponentGroup>
|
</ComponentGroup>
|
||||||
</Fragment>
|
</Fragment>
|
||||||
</Wix>
|
</Wix>
|
||||||
|
|||||||
@@ -136,6 +136,11 @@
|
|||||||
<Custom Action="SetUninstallCommandNotFoundParam" Before="UninstallCommandNotFound" />
|
<Custom Action="SetUninstallCommandNotFoundParam" Before="UninstallCommandNotFound" />
|
||||||
<Custom Action="SetUpgradeCommandNotFoundParam" Before="UpgradeCommandNotFound" />
|
<Custom Action="SetUpgradeCommandNotFoundParam" Before="UpgradeCommandNotFound" />
|
||||||
<Custom Action="SetApplyModulesRegistryChangeSetsParam" Before="ApplyModulesRegistryChangeSets" />
|
<Custom Action="SetApplyModulesRegistryChangeSetsParam" Before="ApplyModulesRegistryChangeSets" />
|
||||||
|
|
||||||
|
<?if $(var.PerUser) = "true" ?>
|
||||||
|
<Custom Action="SetInstallDSCModuleParam" Before="InstallDSCModule" />
|
||||||
|
<?endif?>
|
||||||
|
|
||||||
<Custom Action="SetUnApplyModulesRegistryChangeSetsParam" Before="UnApplyModulesRegistryChangeSets" />
|
<Custom Action="SetUnApplyModulesRegistryChangeSetsParam" Before="UnApplyModulesRegistryChangeSets" />
|
||||||
<Custom Action="CheckGPO" After="InstallInitialize">
|
<Custom Action="CheckGPO" After="InstallInitialize">
|
||||||
NOT Installed
|
NOT Installed
|
||||||
@@ -149,7 +154,10 @@
|
|||||||
<!--<Custom Action="InstallEmbeddedMSIXTask" After="InstallFinalize">
|
<!--<Custom Action="InstallEmbeddedMSIXTask" After="InstallFinalize">
|
||||||
NOT Installed
|
NOT Installed
|
||||||
</Custom>-->
|
</Custom>-->
|
||||||
<Custom Action="TelemetryLogInstallSuccess" After="InstallFinalize">
|
<?if $(var.PerUser) = "true" ?>
|
||||||
|
<Custom Action="InstallDSCModule" After="InstallFiles"/>
|
||||||
|
<?endif?>
|
||||||
|
<Custom Action="TelemetryLogInstallSuccess" After="InstallFinalize">
|
||||||
NOT Installed
|
NOT Installed
|
||||||
</Custom>
|
</Custom>
|
||||||
<Custom Action="TelemetryLogUninstallSuccess" After="InstallFinalize">
|
<Custom Action="TelemetryLogUninstallSuccess" After="InstallFinalize">
|
||||||
@@ -177,8 +185,12 @@
|
|||||||
<!--<Custom Action="UninstallEmbeddedMSIXTask" After="InstallFinalize">
|
<!--<Custom Action="UninstallEmbeddedMSIXTask" After="InstallFinalize">
|
||||||
Installed AND (REMOVE="ALL")
|
Installed AND (REMOVE="ALL")
|
||||||
</Custom>-->
|
</Custom>-->
|
||||||
|
<?if $(var.PerUser) = "true" ?>
|
||||||
|
<Custom Action="UninstallDSCModule" After="InstallFinalize">
|
||||||
|
Installed AND (REMOVE="ALL")
|
||||||
|
</Custom>
|
||||||
|
<?endif?>
|
||||||
<Custom Action="TerminateProcesses" Before="InstallValidate" />
|
<Custom Action="TerminateProcesses" Before="InstallValidate" />
|
||||||
|
|
||||||
<Custom Action="LaunchPowerToys" Before="InstallFinalize">NOT Installed</Custom>
|
<Custom Action="LaunchPowerToys" Before="InstallFinalize">NOT Installed</Custom>
|
||||||
|
|
||||||
</InstallExecuteSequence>
|
</InstallExecuteSequence>
|
||||||
@@ -211,6 +223,10 @@
|
|||||||
Property="UnApplyModulesRegistryChangeSets"
|
Property="UnApplyModulesRegistryChangeSets"
|
||||||
Value="[INSTALLFOLDER]" />
|
Value="[INSTALLFOLDER]" />
|
||||||
|
|
||||||
|
<CustomAction Id="SetInstallDSCModuleParam"
|
||||||
|
Property="InstallDSCModule"
|
||||||
|
Value="[INSTALLFOLDER]" />
|
||||||
|
|
||||||
<CustomAction Id="SetUninstallCommandNotFoundParam"
|
<CustomAction Id="SetUninstallCommandNotFoundParam"
|
||||||
Property="UninstallCommandNotFound"
|
Property="UninstallCommandNotFound"
|
||||||
Value="[INSTALLFOLDER]" />
|
Value="[INSTALLFOLDER]" />
|
||||||
@@ -265,6 +281,21 @@
|
|||||||
DllEntry="UninstallEmbeddedMSIXCA"
|
DllEntry="UninstallEmbeddedMSIXCA"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<CustomAction Id="InstallDSCModule"
|
||||||
|
Return="ignore"
|
||||||
|
Impersonate="yes"
|
||||||
|
Execute="deferred"
|
||||||
|
BinaryKey="PTCustomActions"
|
||||||
|
DllEntry="InstallDSCModuleCA"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<CustomAction Id="UninstallDSCModule"
|
||||||
|
Return="ignore"
|
||||||
|
Impersonate="yes"
|
||||||
|
BinaryKey="PTCustomActions"
|
||||||
|
DllEntry="UninstallDSCModuleCA"
|
||||||
|
/>
|
||||||
|
|
||||||
<CustomAction Id="UninstallServicesTask"
|
<CustomAction Id="UninstallServicesTask"
|
||||||
Return="ignore"
|
Return="ignore"
|
||||||
Impersonate="yes"
|
Impersonate="yes"
|
||||||
@@ -407,6 +438,7 @@
|
|||||||
<Directory Id="INSTALLFOLDER" Name="PowerToys">
|
<Directory Id="INSTALLFOLDER" Name="PowerToys">
|
||||||
<Directory Id="BaseApplicationsAssetsFolder" Name="Assets">
|
<Directory Id="BaseApplicationsAssetsFolder" Name="Assets">
|
||||||
</Directory>
|
</Directory>
|
||||||
|
<Directory Id="DSCModulesReferenceFolder" Name="DSCModules" />
|
||||||
<Directory Id="WinUI3AppsInstallFolder" Name="WinUI3Apps">
|
<Directory Id="WinUI3AppsInstallFolder" Name="WinUI3Apps">
|
||||||
<Directory Id="WinUI3AppsMicrosoftUIXamlInstallFolder" Name="Microsoft.UI.Xaml">
|
<Directory Id="WinUI3AppsMicrosoftUIXamlInstallFolder" Name="Microsoft.UI.Xaml">
|
||||||
<Directory Id="WinUI3AppsMicrosoftUIXamlAssetsInstallFolder" Name="Assets" />
|
<Directory Id="WinUI3AppsMicrosoftUIXamlAssetsInstallFolder" Name="Assets" />
|
||||||
@@ -421,9 +453,6 @@
|
|||||||
<Directory Id="ApplicationProgramsFolder" Name="PowerToys (Preview)"/>
|
<Directory Id="ApplicationProgramsFolder" Name="PowerToys (Preview)"/>
|
||||||
</Directory>
|
</Directory>
|
||||||
<Directory Id="DesktopFolder" Name="Desktop" />
|
<Directory Id="DesktopFolder" Name="Desktop" />
|
||||||
<?if $(var.PerUser) = "true" ?>
|
|
||||||
<Directory Id="PersonalFolder" Name="UserHomeDocuments" />
|
|
||||||
<?endif?>
|
|
||||||
</Directory>
|
</Directory>
|
||||||
</Fragment>
|
</Fragment>
|
||||||
</Wix>
|
</Wix>
|
||||||
|
|||||||
@@ -139,6 +139,23 @@ LExit:
|
|||||||
return SUCCEEDED(hr);
|
return SUCCEEDED(hr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::filesystem::path GetUserPowerShellModulesPath()
|
||||||
|
{
|
||||||
|
PWSTR myDocumentsBlockPtr;
|
||||||
|
|
||||||
|
if (SUCCEEDED(SHGetKnownFolderPath(FOLDERID_Documents, 0, NULL, &myDocumentsBlockPtr)))
|
||||||
|
{
|
||||||
|
const std::wstring myDocuments{ myDocumentsBlockPtr };
|
||||||
|
CoTaskMemFree(myDocumentsBlockPtr);
|
||||||
|
return std::filesystem::path(myDocuments) / "PowerShell" / "Modules";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CoTaskMemFree(myDocumentsBlockPtr);
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
UINT __stdcall LaunchPowerToysCA(MSIHANDLE hInstall)
|
UINT __stdcall LaunchPowerToysCA(MSIHANDLE hInstall)
|
||||||
{
|
{
|
||||||
HRESULT hr = S_OK;
|
HRESULT hr = S_OK;
|
||||||
@@ -162,7 +179,7 @@ UINT __stdcall LaunchPowerToysCA(MSIHANDLE hInstall)
|
|||||||
BOOL isSystemUser = IsLocalSystem();
|
BOOL isSystemUser = IsLocalSystem();
|
||||||
|
|
||||||
if (isSystemUser) {
|
if (isSystemUser) {
|
||||||
|
|
||||||
auto action = [&commandLine](HANDLE userToken) {
|
auto action = [&commandLine](HANDLE userToken) {
|
||||||
STARTUPINFO startupInfo{ .cb = sizeof(STARTUPINFO), .wShowWindow = SW_SHOWNORMAL };
|
STARTUPINFO startupInfo{ .cb = sizeof(STARTUPINFO), .wShowWindow = SW_SHOWNORMAL };
|
||||||
PROCESS_INFORMATION processInformation;
|
PROCESS_INFORMATION processInformation;
|
||||||
@@ -317,6 +334,125 @@ LExit:
|
|||||||
return WcaFinalize(er);
|
return WcaFinalize(er);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const wchar_t* DSC_CONFIGURE_PSD1_NAME = L"Microsoft.PowerToys.Configure.psd1";
|
||||||
|
const wchar_t* DSC_CONFIGURE_PSM1_NAME = L"Microsoft.PowerToys.Configure.psm1";
|
||||||
|
|
||||||
|
UINT __stdcall InstallDSCModuleCA(MSIHANDLE hInstall)
|
||||||
|
{
|
||||||
|
HRESULT hr = S_OK;
|
||||||
|
UINT er = ERROR_SUCCESS;
|
||||||
|
std::wstring installationFolder;
|
||||||
|
|
||||||
|
hr = WcaInitialize(hInstall, "InstallDSCModuleCA");
|
||||||
|
ExitOnFailure(hr, "Failed to initialize");
|
||||||
|
|
||||||
|
hr = getInstallFolder(hInstall, installationFolder);
|
||||||
|
ExitOnFailure(hr, "Failed to get installFolder.");
|
||||||
|
|
||||||
|
{
|
||||||
|
const auto baseModulesPath = GetUserPowerShellModulesPath();
|
||||||
|
if (baseModulesPath.empty())
|
||||||
|
{
|
||||||
|
hr = E_FAIL;
|
||||||
|
ExitOnFailure(hr, "Unable to determine Powershell modules path");
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto modulesPath = baseModulesPath / L"Microsoft.PowerToys.Configure" / get_product_version();
|
||||||
|
|
||||||
|
std::error_code errorCode;
|
||||||
|
fs::create_directories(modulesPath, errorCode);
|
||||||
|
if (errorCode)
|
||||||
|
{
|
||||||
|
hr = E_FAIL;
|
||||||
|
ExitOnFailure(hr, "Unable to create Powershell modules folder");
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const auto* filename : { DSC_CONFIGURE_PSD1_NAME, DSC_CONFIGURE_PSM1_NAME })
|
||||||
|
{
|
||||||
|
fs::copy_file(fs::path(installationFolder) / "DSCModules" / filename, modulesPath / filename, fs::copy_options::overwrite_existing, errorCode);
|
||||||
|
|
||||||
|
if (errorCode)
|
||||||
|
{
|
||||||
|
hr = E_FAIL;
|
||||||
|
ExitOnFailure(hr, "Unable to copy Powershell modules file");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LExit:
|
||||||
|
if (SUCCEEDED(hr))
|
||||||
|
{
|
||||||
|
er = ERROR_SUCCESS;
|
||||||
|
Logger::info(L"DSC module was installed!");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
er = ERROR_INSTALL_FAILURE;
|
||||||
|
Logger::error(L"Couldn't install DSC module!");
|
||||||
|
}
|
||||||
|
|
||||||
|
return WcaFinalize(er);
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT __stdcall UninstallDSCModuleCA(MSIHANDLE hInstall)
|
||||||
|
{
|
||||||
|
HRESULT hr = S_OK;
|
||||||
|
UINT er = ERROR_SUCCESS;
|
||||||
|
|
||||||
|
hr = WcaInitialize(hInstall, "UninstallDSCModuleCA");
|
||||||
|
ExitOnFailure(hr, "Failed to initialize");
|
||||||
|
|
||||||
|
{
|
||||||
|
const auto baseModulesPath = GetUserPowerShellModulesPath();
|
||||||
|
if (baseModulesPath.empty())
|
||||||
|
{
|
||||||
|
hr = E_FAIL;
|
||||||
|
ExitOnFailure(hr, "Unable to determine Powershell modules path");
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto powerToysModulePath = baseModulesPath / L"Microsoft.PowerToys.Configure";
|
||||||
|
const auto versionedModulePath = powerToysModulePath / get_product_version();
|
||||||
|
|
||||||
|
std::error_code errorCode;
|
||||||
|
|
||||||
|
for (const auto* filename : { DSC_CONFIGURE_PSD1_NAME, DSC_CONFIGURE_PSM1_NAME })
|
||||||
|
{
|
||||||
|
fs::remove(versionedModulePath / filename, errorCode);
|
||||||
|
|
||||||
|
if (errorCode)
|
||||||
|
{
|
||||||
|
hr = E_FAIL;
|
||||||
|
ExitOnFailure(hr, "Unable to delete DSC file");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const auto* modulePath : { &versionedModulePath, &powerToysModulePath })
|
||||||
|
{
|
||||||
|
fs::remove(*modulePath, errorCode);
|
||||||
|
|
||||||
|
if (errorCode)
|
||||||
|
{
|
||||||
|
hr = E_FAIL;
|
||||||
|
ExitOnFailure(hr, "Unable to delete DSC folder");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LExit:
|
||||||
|
if (SUCCEEDED(hr))
|
||||||
|
{
|
||||||
|
er = ERROR_SUCCESS;
|
||||||
|
Logger::info(L"DSC module was uninstalled!");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
er = ERROR_INSTALL_FAILURE;
|
||||||
|
Logger::error(L"Couldn't uninstall DSC module!");
|
||||||
|
}
|
||||||
|
|
||||||
|
return WcaFinalize(er);
|
||||||
|
}
|
||||||
|
|
||||||
UINT __stdcall InstallEmbeddedMSIXCA(MSIHANDLE hInstall)
|
UINT __stdcall InstallEmbeddedMSIXCA(MSIHANDLE hInstall)
|
||||||
{
|
{
|
||||||
HRESULT hr = S_OK;
|
HRESULT hr = S_OK;
|
||||||
|
|||||||
@@ -18,10 +18,12 @@ EXPORTS
|
|||||||
CertifyVirtualCameraDriverCA
|
CertifyVirtualCameraDriverCA
|
||||||
InstallVirtualCameraDriverCA
|
InstallVirtualCameraDriverCA
|
||||||
InstallEmbeddedMSIXCA
|
InstallEmbeddedMSIXCA
|
||||||
|
InstallDSCModuleCA
|
||||||
UnApplyModulesRegistryChangeSetsCA
|
UnApplyModulesRegistryChangeSetsCA
|
||||||
UninstallVirtualCameraDriverCA
|
UninstallVirtualCameraDriverCA
|
||||||
UnRegisterContextMenuPackagesCA
|
UnRegisterContextMenuPackagesCA
|
||||||
UninstallEmbeddedMSIXCA
|
UninstallEmbeddedMSIXCA
|
||||||
|
UninstallDSCModuleCA
|
||||||
UninstallServicesCA
|
UninstallServicesCA
|
||||||
UninstallCommandNotFoundModuleCA
|
UninstallCommandNotFoundModuleCA
|
||||||
UpgradeCommandNotFoundModuleCA
|
UpgradeCommandNotFoundModuleCA
|
||||||
|
|||||||
Reference in New Issue
Block a user