|
-
Jul 2nd, 2009, 12:45 PM
#1
Thread Starter
Frenzied Member
[RESOLVED] batch file to uninstall and install program
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,
Code:
@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
-
Jul 4th, 2009, 11:44 AM
#2
Hyperactive Member
Re: batch file to uninstall and install program
Batch files are pretty limited as installers and I would recommend using something like the Inno Setup 5 installer (which is free) or the AutoIT scripting language (which is free), but with being said; you just try to run the uninstaller which is typically found with in the installation directory or under the Window installer directory (if it is an MSI isntaller). If it runs, it is was intalled. If not, it was not. Either way, you just keep going with your script after you try running the uninstaller.
You could also use the IF EXIST command to see if any main components already exist, but this would only work if the user installed to the default directory.
Good Luck!
-
Jul 5th, 2009, 09:02 AM
#3
Fanatic Member
Re: batch file to uninstall and install program
I'm just giving some advices, i haven't tested nothing of this
This batch command can check if a file exists
You can write to some file.BAT some data that your installer is doing
If it creates a directory you write to taht file
rd directory_name
if it makes/copies a file you add a command
del file_name
etc..
When that file is called it will execute those commands and probably unistall your program
Edit:
Command
@echo del C:\test.txt >> Anotherfile.Bat
will open Anotherfile.Bat for append and add a "del C:\test.txt" to it.
Last edited by Dungeon Keeper; Jul 5th, 2009 at 09:06 AM.
No, that wont do!
-
Jul 5th, 2009, 09:13 AM
#4
Fanatic Member
Re: batch file to uninstall and install program
 Originally Posted by Quiver318
You could also use the IF EXIST command to see if any main components already exist, but this would only work if the user installed to the default directory.
Application can be installed anywhere on disk, but a uninstall file can be somewhere else at a known position.
For example \uninstall\MyApp_uninstall.bat
 Originally Posted by Quiver318
Batch files are pretty limited as installers

-
Jul 5th, 2009, 08:23 PM
#5
New Member
Re: batch file to uninstall and install program
for my bat installers, i packed install files into 7-zip(makes it alot smaller) and used a bat installer with zipp.exe, works pretty good, i will have to look closer on it for detecting and uninstalling
-
Jul 7th, 2009, 03:14 AM
#6
Thread Starter
Frenzied Member
Re: batch file to uninstall and install program
Hello,
I managed to solve my problem. I was very simple, I am surprised I didn't think of it before.
However, as I am using MSI I just set the 'removepreviousversion' to true and changed the product code.
This now removes the previous version so there is no need to change anything about my bat file.
Thanks for all the advice,
-
Jul 7th, 2009, 03:19 AM
#7
Thread Starter
Frenzied Member
Re: batch file to uninstall and install program
Hello,
I managed to solve my problem. I was very simple, I am surprised I didn't think of it before.
However, as I am using MSI I just set the 'removepreviousversion' to true and changed the product code.
This now removes the previous version so there is no need to change anything about my bat file.
Thanks for all the advice,
-
Aug 4th, 2010, 11:07 AM
#8
New Member
Re: [RESOLVED] batch file to uninstall and install program
Hi !
I am trying to do something similar. Where can i look for "removepreviousversion" in the MSI file ?
I am using ORCA to edit the msi file.
Thanks in advance!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|