0

How can I find a batch file using a version of Windows installer?

for example:

For /F %%A In ('reg query "HKEY_LOCAL_MACHINE..."') do Echo Windows Installer v3.1 found
For /F %%A In ('reg query "HKEY_LOCAL_MACHINE..."') do Echo Windows Installer v4.0 found
For /F %%A In ('reg query "HKEY_LOCAL_MACHINE..."') do Echo Windows Installer v4.5 found

What registry keys should I use?

thekbb
  • 7,668
  • 1
  • 36
  • 61
Olga
  • 1,395
  • 2
  • 25
  • 34

2 Answers2

1

Are you talking about msiexec.exe ?

; @echo off
;call :fileinf /l "%windir%\System32\msiexec.exe"
; echo   windows installer version %vern%
;pause
;goto :eof
;:fileinf
;;setlocal DISABLEDELAYEDEXPANSION ENABLEEXTENSIONS
;;goto :end_help
;;;
;;;
;;; fileinf /l list of full file paths separated with ; (if file is more than one enclose all of them in double quotes)
;;; fileinf /f text file with a list of files to be processed ( one on each line )
;;; fileinf /? prints the help
;;;
;;:end_help

; REM Creating a Newline variable (the two blank lines are required!)
; set NLM=^


; set NL=^^^%NLM%%NLM%^%NLM%%NLM%
; if "%~1" equ "/?" type "%~f0" | find ";;;" | find /v "find" && exit /b 0
; if "%~2" equ "" type "%~f0" | find ";;;" | find /v "find" && exit /b 0
; setlocal enableDelayedExpansion
; if "%~1" equ "/l" (
;  set "_files=%~2"
;  echo !_files:;=%NL%!>"%TEMP%\file.paths"
;  set _process_file="%TEMP%\file.paths"
;  goto :get_info
; )

; if "%~1" equ "/f" if exist "%~2" (
;  set _process_file="%~2"
;  goto :get_info
; )

; echo incorect parameters & exit /b 1
; :get_info
; set "file_info="

; makecab /d InfFileName=%TEMP%\file.inf /d "DiskDirectory1=%TEMP%" /f "%~f0"  /f %_process_file% /v0 >nul 2>&1

; for /f "usebackq skip=4 delims=" %%f in ("%TEMP%\file.inf") do (
;  set "line=%%f" 
;  set "line=!line::==!"
;  set "file_info=!line!"
; )


;for %%v in ("%file_info%") do (set %%~v)

;endlocal& set "vern=%vern%"
;endlocal& set "vern=%vern%"
; del /q /f %TEMP%\file.inf 2>nul
; del /q /f %TEMP%\file.path 2>nul
; exit /b 0

.set DoNotCopyFiles=on
.set DestinationDir=;
.set RptFileName=nul
.set InfFooter=;
.set InfHeader=;
.Set ChecksumWidth=8
.Set InfDiskLineFormat=;
.Set Cabinet=off
.Set Compress=off
.Set GenerateInf=ON
.Set InfDiskHeader=;
.Set InfFileHeader=;
.set InfCabinetHeader=;
.Set InfFileLineFormat="vern:*ver*"

OR

WMIC DATAFILE WHERE name="C:\\Windows\\System32\\msiexec.exe" get Version /format:Textvaluelist
npocmaka
  • 55,367
  • 18
  • 148
  • 187
  • `set NL=^^^%NLM%%NLM%^%NLM%%NLM%` Huh? the more u use cryptic letters the better is your Batch competence :) – Endoro Dec 12 '13 at 08:00
  • It's a standard way to assign a new line to a variable and is widely used in batch scripts -> http://stackoverflow.com/questions/6379619/explain-how-dos-batch-newline-variable-hack-works – npocmaka Dec 12 '13 at 08:03
  • Batch scripts are still widely used? – Christopher Painter Dec 12 '13 at 13:06
  • That's not what I said :-) .But it's debatable how valuable is the knowledge in batch scripting.I think it's more more popular than powershell which on the other hand puts down the usage of vbscript/jscript. – npocmaka Dec 12 '13 at 13:34
  • I know what's he's trying to do and .BAT is not the way to go. Nor is PowerShell or VBScript. Moving on... – Christopher Painter Dec 12 '13 at 14:39
1

It sounds like you are trying to make a bootstrapper / chainer. .BAT is not appropriate for that task. You should look at Windows Installer XML (WiX) "Burn" bootstrapper. You can use this to create an EXE that will chain together your MSI and .NET prereqs before installing your MSI.

Christopher Painter
  • 54,556
  • 6
  • 63
  • 100