[Webinar] Streamline your web hosting managementRegister Today

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 503
  • Last Modified:

MS DOS scirpt to install and uninstall the application

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?
  • 8
  • 6
2 Solutions
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

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
SaggiAuthor Commented:
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?
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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.

SaggiAuthor Commented:
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
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.
SaggiAuthor Commented:
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?
SaggiAuthor Commented:
Un install works I havenot used the braces {} earliar for the GUID.
Issue with the install.
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.
SaggiAuthor Commented:
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?
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
SaggiAuthor Commented:
So as I understand from you we cannot do silent install setup.exe from a command prompt.
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.
SaggiAuthor Commented:
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.
SaggiAuthor Commented:
In my case its not possible to get the solution.

Featured Post

Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

  • 8
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now