在 msi 安装程序项目中卸载 Windows SDK

问题描述 投票:0回答:2

我使用 microsoft Visual Studio 2022 创建了一个 msi 安装程序,我可以在其中安装从 signtool 安装步骤中读取的signtool.exe

这是我在 .bat 文件中使用的命令:%LOCALAPPDATA%\Microsoft\MicrosoftTrustedSigningClientTools\winsdksetup.exe /features OptionId.SigningTools /q /norestart

是否还有类似的卸载命令,我可以在我的 msi 的卸载自定义操作中使用它来删除signtool.exe及其依赖项?

visual-studio installation windows-installer
2个回答
1
投票

你的问题其实与VS无关,对于你的要求,我认为你有两种方法:

1, 获取exe文件的位置并在BAT文件中使用这样的命令将其删除:

@echo off
REM Replace the path below with the actual path to your signtool.exe
DEL "C:\Path\To\signtool.exe"
echo signtool.exe has been deleted.
pause

2、使用msiexec:

看看这个答案:

如何使用 msiexec 卸载特定功能

这是它的官方文档:

msiexec 文档

/qn 应该可以帮助您安静卸载。


0
投票

我必须创建一个像这样的小型控制台应用程序:

    // See https://aka.ms/new-console-template for more information
using System.ComponentModel;

string strCmdSignToolInstall;
strCmdSignToolInstall = "/c \"%LOCALAPPDATA%\\Microsoft\\MicrosoftTrustedSigningClientTools\\winsdksetup.exe\" /features OptionId.SigningTools /q /norestart";

try
{
    var signToolProcess = System.Diagnostics.Process.Start("C:\\WINDOWS\\System32\\CMD.exe", strCmdSignToolInstall);
}
catch (Win32Exception ex)
{
    Console.WriteLine("Following error occured while installing signtool.exe \n" + ex.Message);
    Console.WriteLine("Please run the following command manually" + Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
+ "\\Local\\Microsoft\\MicrosoftTrustedSigningClientTools\\winsdksetup.exe / features OptionId.SigningTools / q / norestart");
}
catch (Exception ex)
{
    Console.WriteLine("Following error occured while installing signtool.exe \n" + ex.Message);
    Console.WriteLine("Please run the following command manually" + Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
+ "\\Local\\Microsoft\\MicrosoftTrustedSigningClientTools\\winsdksetup.exe / features OptionId.SigningTools / q / norestart");
}

我在自定义操作的 msi 项目 (*.vdproj) 中调用此程序,如下所示:

© www.soinside.com 2019 - 2024. All rights reserved.