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

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.
snehal jadhavAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

@echo off
title Multiple Choice Menu
echo Select a task:
echo =============
echo 1) Install Silently 
echo 2) Uninstall program
echo 3) install program
echo 4) run another bat file
echo 5) Exit
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
echo Listing files from c:\windows\temp
dir c:\windows\temp /p /b
goto home

Open in new window

NVITEnd-user supportCommented:
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

Open in new window

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

RunMSI.bat /silent
RunMSI.bat /x

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
NVITEnd-user supportCommented:
Question answered
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.