Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


MS DOS scirpt to install and uninstall the application

Posted on 2010-09-24
Medium Priority
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?
Question by:Saggi
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 6

Expert Comment

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)
 c:\Application\<app_uninstallfile Name>
2. save it as uninstall.bat (or whatever name u like)

In install Batch file write following: ( ie open a text file and write)
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


Accepted Solution

Lotok earned 2000 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

Author Comment

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?
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments


Expert Comment

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.


Author Comment

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

Expert Comment

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

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

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.

Author Comment

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?

Author Comment

ID: 33768880
Un install works I havenot used the braces {} earliar for the GUID.
Issue with the install.

Expert Comment

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.

Author Comment

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?

Assisted Solution

Lotok earned 2000 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

Author Comment

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

Expert Comment

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.

Author Comment

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.

Author Closing Comment

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

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

609 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