Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.
July 19, 2005
I have scripted WMIMSI.bat to allow you to install a .MSI from a WMI script.
The syntax for using WMIMSI.bat is:
WMIMSI ALL PackagePath [PackageParms]
Where:
ALL is Y if you wish the package to be available to all users, or N if you wish the package to be available only to the user who runs the WMIMSI.bat script.PackagePath is the path to the package. URL format is allowed.PackageParms are installation parameters that the package accepts.
WMIMSI.bat contains:
@echo offif {%2}
{} @echo Syntax: WMIMSI ALL PackagePath [Package Installation Parameters]&goto :EOFif not exist %2 @echo Syntax: WMIMSI ALL PackagePath [Package Installation Parameters] - %2 NOT found.&goto :EOFif /i {%1}
{Y} goto OKif /i {%1}
{N} goto OK@echo Syntax: WMIMSI ALL PackagePath [Package Installation Parameters] - %1 NOT Y or N.&goto :EOF:OKsetlocalset pkg=%2set pkg="%pkg:"=%"set wrk="%TEMP%WMIMSI_%RANDOM%.VBS%"if /i {%1}
{Y} ( @echo Const ALL_USERS = True>%wrk% ) ELSE ( @echo Const ALL_USERS = False>%wrk%)@echo Set objService = GetObject("winmgmts:")>>%wrk%@echo Set objSoftware = objService.Get("Win32_Product")>>%wrk%for /f "Tokens=1,2*" %%a in ('@echo %*') do ( @echo errReturn = objSoftware.Install(%pkg%, %%c, ALL_USERS)>>%wrk%)::cscript //nologo %wrk%type %wrk%del /q %wrk%endlocal
You May Also Like