我正在使用以下bat文件將我的應用程序安裝到用戶計算機上。但是,如果應用程序已安裝,則客戶端希望能夠卸載應用程序,然後安裝新版本的應用程序。bat文件來卸載已安裝的應用程序
但是,我有2個問題。
1)如何檢測應用程序是否安裝?
2)如果安裝了,我該如何卸載它?
應用程序是一個C#2005
@ECHO OFF
:: Copy the configuration file
copy config.xml "%AppData%\DataLinks.xml"
:: Search for the CONFIG file, if this doesn't exit then the user doesn't have the .Net framework 2.0
SET FileName=%windir%\Microsoft.NET\Framework\v2.0.50727\CONFIG
IF EXIST %FileName% GOTO INSTALL_DIALER
ECHO.You currently do not have the Microsoft(c) .NET Framework 2.0 installed.
ECHO.This is required by the setup program for CAT Dialer
ECHO.
ECHO.The Microsoft(c) .NET Framework 2.0 will now be installed on you system.
ECHO.After completion setup will continue to install CAT Dialer on your system.
ECHO.
:: Install the .Net framework and then run setup to install the CAT Dialerr
PAUSE
ECHO Installing... this could take several minutes...Please wait....
START /WAIT NetFx20SP2_x86.exe
:: If the user cancels the installation of the framework exit batch file
IF errorlevel 1 GOTO EOF
Start CATSoftphone.exe
ECHO ON
EXIT
:: .Net framework has been skipped contine to install the dialer.
:INSTALL_DIALER
ECHO *** Skiped Dotnet Framework 2.0.50727 ***
ECHO Installing... Please wait...
START CATSoftphone.exe
ECHO ON
EXIT
編輯==============================
<job id="ReInstall">
<script language="VBScript">
Dim WshShell, oExec
Set WshShell = CreateObject("WScript.Shell")
oExec = WshShell.Run("msiexec /uninstall {2E92DD55-37E9-4D6C-B55B-DAFD9DF583E2}" , 1 , true)
If oExec = 0 OR oExec = 1605 Then
oExec = WshShell.Run("InstallUninstallBat.msi")
End If
</script>
</job>
您好,我測試了您的腳本文件,並添加了我自己的productcode和msi名稱。但是,當我運行它只是快速閃爍,並沒有做任何事情。我錯過了什麼。我用我的腳本編輯了我的代碼。謝謝。 – ant2009 2009-07-02 17:32:57