- NSIS Discussion
- Windows and MS Office Version
Archive: Windows and MS Office Version
aemik
25th June 2007 12:09 UTC
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
25th June 2007 12:15 UTC
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
25th June 2007 13:19 UTC
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
25th June 2007 13:27 UTC
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)
aemik
26th June 2007 08:30 UTC
How can I check the existence of folders or keys in the registry? Cant find any command...
sgiusto
26th June 2007 10:04 UTC
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
26th June 2007 11:48 UTC
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
26th June 2007 14:35 UTC
Use:
ClearErrors
ReadRegStr ...
${If} ${Errors}
...
${EndIf}
The error flag is set if a key cannot be found.
Stu
Joel
26th June 2007 16:17 UTC
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 :p
DetailPrint "No word detected!!!"
End:
SectionEnd
aemik
27th June 2007 08:09 UTC
Thanks. That is a good idea.
But isn't it possible to check if folder exists???
Afrow UK
27th June 2007 11:58 UTC
IfFileExists "path\*.*"
Stu
aemik
27th June 2007 12:31 UTC
Thank you very much.
It works for for the normal filesystem.
But how does it work in the registry?
aemik
Afrow UK
27th June 2007 13:11 UTC
Each folder has a default key in the registry (I think) so:
ClearErrors
ReadRegStr $R0 HKLM "Software\Whatever" ""
${If} ${Errors}
...
${EndIf}
Stu
kichik
27th June 2007 13:27 UTC
See Check for a Registry Key in the Wiki.
aemik
28th June 2007 08:06 UTC
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
Afrow UK
28th June 2007 11:37 UTC
Did you not see Joel's post above?
Stu