Solved

MS DOS scirpt to install and uninstall the application

Posted on 2010-09-24
15
492 Views
Last Modified: 2012-05-10
I have application installed in C:\Application which needs to be uninstalled and install the new Application which has the setup.exe in C:\Software\Setup.exe

I want script to unstall and  install in silent mode from a batch file?
0
Comment
Question by:Saggi
  • 8
  • 6
15 Comments
 
LVL 2

Expert Comment

by:rupeshsaini
ID: 33752740
Make a bat file or open a text file and save as name.bat file.

U have to make two bat =batch file

-one to uninstall and another to install
-Shedule the Install Batch file after unistall file (ie. after the application uninstall)

In Uninstall Batch file write following: ( ie open a text file and write)
1.
 c:\Application\<app_uninstallfile Name>
 exit
2. save it as uninstall.bat (or whatever name u like)

In install Batch file write following: ( ie open a text file and write)
1.
 C:\Software\Setup.exe
 exit
2. save the text file as filename.bat

Now just u have to shedule the two batch file accordingly
For sheduling u can use Control Panel--> shedule task

Regards
RS
0
 
LVL 8

Accepted Solution

by:
Lotok earned 500 total points
ID: 33752789
When you run the setup.exe does it extract an MSI? Many exe files are wrappers for msi files. Is this a bespoke app or one I might know? (I can then advise if it has an msi if its one I know).

every MSI has a GUID (Global Unique Identifier) which is used for the uninstall.

the commandline to install is:

msiexec.exe /i <msiname>.msi /qn

the commandline to uninstall would be
msiexec.exe /x <msiguid> /qn


If you need to find the GUID you have a few options. If there is an uninstall icon look at its properties, it will be in there.
If you created the msi you can get it from the package details
If its 3rd party you can use ORCA by microsoft.


If the setup.exe doesnt unpack an msi, then you need to know if the exe supports commandline switches like /s or /q
0
 

Author Comment

by:Saggi
ID: 33752972
This is clinical services application which was developed by company.
I don't see any uninstall option in start up eitther.
Applcation was installed in C: Drive folder CS which have ClinicalService.exe with many other folders.
Iam not sure how to uninstall from command prompt.

I have new setup.exe which is in C:\Software\Setup.exe which needs to be installed after uninstalling the old version.
I tried C:\Software\Setup.exe /x it didn't work,  shows up a dialog to upgrade....

I have the install shield setup package where can I find the GUID details in setup.ism?
0
 
LVL 8

Expert Comment

by:Lotok
ID: 33753081
If it has been developed in-house can you ask your developers if the exe supports commandline?
It depends how the application has been packaged, not all exe packages will allow you to install/uninstall from commandline.

the /x command is for use with an MSI. an EXE wont have a GUID.

If it is install shield, then manually open the exe. While the diaglogue is open for installation check C:\temp\ and c:\program files\common files and c:\program files\install sheild*

If there is a wrapped MSI it will be in one of those locations. Then you can use what I said above.
If there is no MSI you need to look at documentation or ask the developer about commandline support as not all EXE files allow it.

0
 

Author Comment

by:Saggi
ID: 33768388
While installing the product I see the project.ism file In C:\Documents and Settings\Sagar\Local Settings\Temp\_is57 folder

Whil uninstall also it looks like GUID with folder name created in the same path C:\Documents and Settings\Sagar\Local Settings\Temp\{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}

These floders {GUID} (uninstall)and _is57(install) are for only temporary once install/uninstall compLtes these folders are deleted.

Now I tried for uninstall
C:\WINDOWS\system32>msiexec.exe /X <GUID> /qn it didn't work.
I also tried C:\WINDOWS\system32>msiexec.exe /X <GUID> without /qn options it showed a message box "Do you want to uninstall the product" when I click Yes is show a message box with
"THIS INSTALLATION PACKAGE COULD NOT BE OPENED. VERIFY THAT THE PACKAGE EXISTS AND THAT YOU CAN ACCESS IT......................."
0
 
LVL 8

Expert Comment

by:Lotok
ID: 33768446
you need to open the installer so the _is57 folder is created. You then need to copy out the contents to another directory. You can then cancel the installer.

So now you have a directory with required files you can create the command lines

INSTALL
msiexec.exe /i fullpath\msiname.msi /qn

UNINSTALL
C:\WINDOWS\system32>msiexec.exe /X <GUID> /qn

The uninstall using that guid will only work AFTER you have installed from that msi.

If you need to uninstall and old version by commandline before you do the install you need to find out if it has its own GUID from a previous msi, or find out if there is an uninstall utility. If neither exist you need to manually uninstall it.

The only way you could script the manual uninstall is find developer install notes, reverse engineer them. So a .BAT file deleting files and directories and unregistering DLLs could be made.
0
 

Author Comment

by:Saggi
ID: 33768735
Iam writing this script for the purpose that it will uninstall and install each time a new build/MSI created. This process will be automated from a tool.

Copying the MSI installer into a different directory may work for once but when next new build comes it will not work unless someone copies into a different directory again. This will not solve problem.

I have installed new build and then tried to uninstall from the cmd prompt as you said C:\WINDOWS\system32>msiexec.exe /X <GUID> /qn it didn't work.

 When I make some changes in the code and new MSI is builded then GUID also changes each build?
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:Saggi
ID: 33768880
Un install works I havenot used the braces {} earliar for the GUID.
Issue with the install.
0
 
LVL 8

Expert Comment

by:Lotok
ID: 33769143
The GUID is unique to the MSI. it wont change unless the MSI changes.

You only need to copy the MSI out of that directory once. Store it on a share somewhere and then the commandline for install can be

msiexec.exe /i "\\myshare\path\mymsi.msi" /qn

Once you have the MSI out of the exe wrapper there is no need to run the exe again. the only exception is old installshield EXE's and new ones where the developer is lazy and ties params direct to the EXE. In most instances this isnt the case.
0
 

Author Comment

by:Saggi
ID: 33776271
Can you explain little clearly I didn't understand if I copy the MSI and install then each time Iam installing from the same location and the same MSI, how it was linked/upated with new MSI(setup.exe) which was builded each time.
For every 2 days I get a new build setup.exe, how this was linked to the MSI which I have stored from the previous setup.exe?
0
 
LVL 8

Assisted Solution

by:Lotok
Lotok earned 500 total points
ID: 33776304
Ah ok, you hadn't made it clear you were making a new MSI every 2 days,
Can your developer not just wrap the app in the MSI to bypass the extraction step? If they know you need an MSI its daft to hand you an EXE.

If they can provide MSI's then problem solved.
If not you will need to add a few extra steps to run the EXE and copy the directory using BAT file. But that wont be silent as the intial EXE dialogue box will show
0
 

Author Comment

by:Saggi
ID: 33786350
So as I understand from you we cannot do silent install setup.exe from a command prompt.
0
 
LVL 8

Expert Comment

by:Lotok
ID: 33786393
some exe's support it as discussed in the first few posts, but not all. /s or /qn are the silent switches to try. If they dont work then you need the msi.
0
 

Author Comment

by:Saggi
ID: 34008137
I dont see exe support silent switches. I don't have access to get/create MSI from the company management.
I will close this question.
0
 

Author Closing Comment

by:Saggi
ID: 34008144
In my case its not possible to get the solution.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now