how to write batch script and VBscript for Install and uninstall an MSI. if /x then uninstall. If /silent  then silent install

snehal jadhav
snehal jadhav used Ask the Experts™
on
suppose eg arg.bat or arg.vbs run on cmd output is installed
   and we can pass the argument
     >arg.bat  /x
      olp : will be uninstallled the msi.
    >arg.bat /silent
    o/p:will  be installed the msi.

 >arg.vbs  /x
      olp : will be uninstallled the msi.
    >arg.vbs  /silent
    o/p:will  be installed the msi.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
Why not use Powershell?
Tahir QureshiSystem Analyst
Commented:
pretty easy open notepad and type the following command and save as "abc.bat"

@echo off
title Multiple Choice Menu
:home
cls
echo.
echo Select a task:
echo =============
echo.
echo 1) Install Silently 
echo 2) Uninstall program
echo 3) install program
echo 4) run another bat file
echo 5) Exit
echo.
set /p web=Type option:
if "%web%"=="1" msiexec.exe /i c:\setup.msi /QN /L*V "C:\Temp\msilog.log"
if "%web%"=="2" msiexec.exe /x c:\setup.msi /QN /L*V "C:\Temp\msilog.log"
if "%web%"=="3" msiexec.exe /i c:\setup.msi  /L*V "C:\Temp\msilog.log"
if "%web%"=="4" Call cleanup.bat
if "%web%"=="5" exit
goto home
:list
echo Listing files from c:\windows\temp
dir c:\windows\temp /p /b
Pause
goto home

Open in new window

End-user support
Commented:
To answer the question of handling CMD arguments...
Here is a simple version:
@echo off
if [%1]==[/x] echo msiexec.exe /x
if [%1]==[/silent] echo msiexec.exe /silent
if [%1]==[] echo Missing argument
pause

Open in new window



If the file is named: RunMSI.bat, then:

RunMSI.bat /silent
RunMSI.bat /x

Open in new window

NVITEnd-user support

Commented:
Question answered

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial