Skip to content
⌘ NSIS Forum Archive

Windows and MS Office Version

16 posts

aemik#

Windows and MS Office Version

Hello,

How can I check which Windows and MS Office Version is installed on the Computer? (Registry? Where there?)

Only e.g. if Win XP (or newer) and Office 2003 (or newer) is installed, the installer will start. How can I program this???

thank you for help
aemik
Afrow UK#
Firstly use LogicLib.nsh and WinVer.nsh for the Windows check,

${If} ${AtleastWinXP}
...
${EndIf}

As for Office 2003 it is up to you to search the registry. Use the search feature in regedit.

Stu
aemik#
Thank you very much.
Its very easy check the Windows Version with this script.

But I dont know how to check the Office Version on the same way. Cant find something in the reg.
sgiusto#
in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office you can find one or more keys with versions of office components installed (8.0, 9.0, 10.0, 11.0, 12.0, ....)
You can test existence of such keys.
Otherwise you can use office component object model and 'ask' office which version is (much more complex, but more reliable for usage with vista/future office reelases)
sgiusto#
You can use EnumRegKey to get all the keys in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office and then to check which version is installed. Read manual for usage of EnumRegKey
aemik#
I only want to check which programs (office e.g.) are installed. version is not so important...

Function .onInit
${If} HKLM Software\Microsoft\Office not exists
MessageBox MB_ICONEXCLAMATION "Office is not isntalled!"
Abort
${EndIf}
FunctionEnd

can somebody help me to convert this code in real commands?
Afrow UK#
Use:

ClearErrors
ReadRegStr ...
${If} ${Errors}
...
${EndIf}

The error flag is set if a key cannot be found.

Stu
Joel#
In the past I used something like this:

Name "OfficePaths"
OutFile "OfficePaths.exe"
ShowInstDetails show
XPStyle on

Section
; Get the path from the registry bunch of "paths"
ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Winword.exe" "Path"
; Test if the file path really exists
IfFileExists "$0winword.exe" true false
true:
; If we here, means that it does exists
DetailPrint "Word installed in:"
DetailPrint "$0winword.exe"
; get version, you know M$ uses the same version for all its Office products..(in same cases)
GetDllVersion "$0winword.exe" $R0 $R1
IntOp $R2 $R0 / 0x00010000
IntOp $R3 $R0 & 0x0000FFFF
IntOp $R4 $R1 / 0x00010000
IntOp $R5 $R1 & 0x0000FFFF
; print it
StrCpy $1 "$R2.$R3.$R4.$R5"
DetailPrint "Word version:"
DetailPrint "$1"
; End the app
goto End
false:
; If we here, means that we been hacked..or office word is not installed 😛
DetailPrint "No word detected!!!"
End:
SectionEnd
aemik#
Thank you very much.
It works for for the normal filesystem.
But how does it work in the registry?

aemik
Afrow UK#
Each folder has a default key in the registry (I think) so:
ClearErrors
ReadRegStr $R0 HKLM "Software\Whatever" ""
${If} ${Errors}
...
${EndIf}

Stu
aemik#
when i look at the properties of winword.exe or excel.exe in the office folder, I can see the version and other informations. is it possible to get the version number of winword.exe to NSIS???

Thank you very much for your help.
Aemik