这将是非常具体的InstallShield,所以我怀疑以前有人处理过这个问题,但我写了一个批处理文件来卸载我们产品的以前版本,它不起作用。(我们总是在安装/升级之前卸载以前的版本,因为InstallShield中的升级似乎不起作用)。卸载Installscript MSI项目与典型的卸载非常不同,因为您需要“记录”卸载并将结果存储在文件中,即:
setup.exe /x /r /f1"C:\temp\UNINST.ISS"
这会将卸载映像存储在c:\ temp\UNINST.ISS中,然后您需要将其传递给卸载程序以获取要卸载的产品:
setup.exe /s /f1"UNINST.ISS"
所以我对我们产品的所有先前版本都这样做了,然后编写了一个批处理脚本(产品代码为{7F2A0A82-BB08-4062-85F8-F21BFC3F3708})来执行如下的卸载:
echo Uninstalling 5.3.0
pause
if exist "C:\Program Files (x86)\InstallShield Installation Information\ {7F2A0A82-BB08-4062-85F8-F21BFC3F3708}\setup.exe" (
del /q "C:\Program Files (x86)\InstallShield Installation Information\{7F2A0A82-BB08-4062-85F8-F21BFC3F3708}\setup-5.3.0.exe"
copy /y "C:\Program Files (x86)\InstallShield Installation Information\{7F2A0A82-BB08-4062-85F8-F21BFC3F3708}\setup.exe" "C:\Program Files (x86)\InstallShield Installation Information\{7F2A0A82-BB08-4062-85F8-F21BFC3F3708}\setup-5.3.0.exe"
cls
echo Uninstalling 5.3.0
"C:\Program Files (x86)\InstallShield Installation Information\{7F2A0A82-BB08-4062-85F8-F21BFC3F3708}\setup-5.3.0.exe" /s /f1".\Uninstall response files\5.3.0\UNINST-5.3.0.ISS"
:wait1
timeout /t 3 /NOBREAK > nul
tasklist | find /i "Setup-5.3.0.exe" >nul 2>nul
if not errorlevel 1 goto wait1
)
echo Uninstalling 5.3.1...
问题是它不起作用。如果我从提升的CMD窗口执行卸载,它可以正常工作:
"C:\Program Files (x86)\InstallShield Installation Information\{7F2A0A82-BB08-4062-85F8-F21BFC3F3708}\setup-5.3.0.exe" /s /f1".\Uninstall response files\5.3.0\UNINST-5.3.0.ISS"
但是,当我执行批处理脚本时,它似乎正好经过卸载,什么也不做。所以我想我应该试着写一个简单的C程序来实现这一点,但这也不管用:
Console.Clear();
Console.WriteLine("Uninstalling 5.3.0");
if (File.Exists(@"C:\Program Files (x86)\InstallShield Installation Information\{7F2A0A82-BB08-4062-85F8-F21BFC3F3708}\setup.exe"))
{
File.Copy(@"C:\Program Files (x86)\InstallShield Installation Information\{7F2A0A82-BB08-4062-85F8-F21BFC3F3708}\setup.exe", @"C:\Program Files (x86)\InstallShield Installation Information\{7F2A0A82-BB08-4062-85F8-F21BFC3F3708}\setup-5.3.0.exe", true);
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = @"C:\Program Files (x86)\InstallShield Installation Information\{7F2A0A82-BB08-4062-85F8-F21BFC3F3708}\setup-5.3.0.exe";
Directory.SetCurrentDirectory(@"..\..\..\");
startInfo.Arguments = "/s / f1\".\\Uninstall response files\\5.3.0\\UNINST-5.3.0.ISS\"";
startInfo.UseShellExecute = false;
startInfo.WindowStyle = ProcessWindowStyle.Normal;
using (Process process = new Process())
{
process.StartInfo = startInfo;
process.Start();
process.WaitForExit();
}
}
Directory.GetCurrentDirectory()
),但我得到这个错误:
process.StandardError' threw an exception of type 'System.InvalidOperationException' System.IO.StreamReader {System.InvalidOperationException}