Windows Develop Bookmark and Share   
 index > ClickOnce and Setup & Deployment Projects > Creating a batch file to install/uninstall application
 

Creating a batch file to install/uninstall application

hello,

I am using the following bat file to install my application on a user computer. However, the client want to be able uninstall the application if the application is installed, and then install the new version of the application.

However, I have 2 problems.

1) how can I detect if the application is installed or not?

2) If it is installed, how can I uninstall it?

The application is a C# 2005.

Many thanks for any advice,

@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 serveral 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


steve1_rm  Friday, July 03, 2009 1:07 AM
If you were to use RemovePreviousVersions in a setup project this automatically uninstalls the older version (assuming it is just an earlier version of your setup).
Phil Wilson
PhilWilson  Monday, July 06, 2009 10:34 PM
If you were to use RemovePreviousVersions in a setup project this automatically uninstalls the older version (assuming it is just an earlier version of your setup).
Phil Wilson
PhilWilson  Monday, July 06, 2009 10:34 PM
Hi,

You can use WMI to check if a software has been installed and uninstall it easily. Please visit the following link for more information:
http://msdn.microsoft.com/en-us/library/aa394588(VS.85).aspx

Hope this helps.

Sincerely,
Linda Liu
Please remember to mark the replies as answers if they help and unmark them if they provide no help. end us any feedback you have about the help from MSFT at fbmsdn@microsoft.com.
Linda Liu  Monday, July 13, 2009 7:37 AM

You can use google to search for other answers

Custom Search

More Threads

• Install Somebody's ClickOnce
• Question about updating the .exe and 1 .dll after intial setup.
• Tracking ClickOnce User Updates
• Creating a web publish package installation
• No-touch deployment .NET Framework 1.1
• Need to remove PrintForms DEPLOY file from cd burn list
• msjro.dll
• Signing application that includes controls developed by another
• Versioning ClickOnce
• Question on ClickOnce Deployment