This is checking for Window Media Player is installed or not, if not get it and install but there is error...
Please, any expert on this, help me. newbie at NSIS.
< Error occurred at here --------------------------- >
EnumRegKey $wmpVersion HKLM "SOFTWARE\Microsoft\Windows Media\Format" $R0
< -------------------------------------------------- >
--Paul
;---------------------------------------------------------
Function checkForWMP
Push $R0
StrCpy $installWMP "no"
StrCpy $R0 0
Goto search
search:
EnumRegKey $wmpVersion HKLM "SOFTWARE\Microsoft\Windows Media\Format" $R0
;SOFTWARE\Microsoft\Windows Media\Format" $R0
IfErrors notfound
StrCpy $wmpVersion $wmpVersion 3
;StrCmp $wmpVersion "9" found
;StrCmp $wmpVersion "10" found
StrCmp $wmpVersion "11" found
StrCmp $wmpVersion "" notfound
IntOp $R0 $R0 + 1
Goto search
notfound:
MessageBox MB_YESNO "You need the latest Window Media Player to use this Software. Install one now?$\n\
Choosing No will abort the installation of the player." \
IDYES install \
IDNO noinstall
Goto done
install:
StrCpy $installWMP "yes"
MessageBox MB_OK "The Latest Window Media Player needs to be downloaded. Please establish a connection to$\n\
the Internet and then click on OK to continue."
NSISdl::download /TIMEOUT=30000 "http://www.myDigit.com/pcplayer/wmp11-windowsxp-x86-enu.exe" "$INSTDIR\wmp11-windowsxp-x86-enu.exe"
Pop $R0 ;Get the return value
StrCmp $R0 "success" done
MessageBox MB_OK "Download of Window Media Player failed: $R0$\nAborting installation..."
Quit
Goto done
noinstall:
Quit
found:
;MessageBox MB_OK "Found WMP version: $wmpVersion"
Goto done
done:
Pop $R0
FunctionEnd
EnumRegKey error! Please help -
9 posts
Are you sure you need enum here? My registry has a single string named "Format" containing "11.0.0.5145" in "HKLM\SOFTWARE\Microsoft\Windows Media"
Have you tried...
... using ReadRegStr or maybe the IfKeyExists macro from the NSIS wiki: http://nsis.sourceforge.net/Check_for_a_Registry_Key
... using ReadRegStr or maybe the IfKeyExists macro from the NSIS wiki: http://nsis.sourceforge.net/Check_for_a_Registry_Key
I am a completely NEWBie...
Anders is right. Then what do I need to do?
"HKLM\SOFTWARE\Microsoft\Windows Media"
step 1. I get the format value (11.0..)
step 2. I store it into
step 3. if the value is less than 11.
step 4. prompt user to shall upgrade?
step 5. if the format doesn't exist,
step 6. prompt user to download...
This is the whole logic.
What do I need to do that? step 1.
Anders is right. Then what do I need to do?
"HKLM\SOFTWARE\Microsoft\Windows Media"
step 1. I get the format value (11.0..)
step 2. I store it into
step 3. if the value is less than 11.
step 4. prompt user to shall upgrade?
step 5. if the format doesn't exist,
step 6. prompt user to download...
This is the whole logic.
What do I need to do that? step 1.
;----------------------------------------------------------
!insertmacro IfKeyExists "ROOT" "KeyToCheckIn" "KeyToCheck"
Pop $R0
;$R0 contains 0 (not present) or 1 (present)
;----------------------------------------------------------
DrDan, in my case, what do I need to put in the place of
1. "ROOT"
2. "KeyToCheckIn"
3. "KeyToCheck"
It will be really appreciated.
!insertmacro IfKeyExists "ROOT" "KeyToCheckIn" "KeyToCheck"
Pop $R0
;$R0 contains 0 (not present) or 1 (present)
;----------------------------------------------------------
DrDan, in my case, what do I need to put in the place of
1. "ROOT"
2. "KeyToCheckIn"
3. "KeyToCheck"
It will be really appreciated.
!insertmacro IfKeyExists "ROOT"
"HKLM\SOFTWARE\Microsoft\Windows Media" "Format"
Pop $R0
DrDan, is it like this?
"HKLM\SOFTWARE\Microsoft\Windows Media" "Format"
Pop $R0
DrDan, is it like this?
You need to do something like
Try this in a barebones installer to make sure it does what you think.
!insertmacro IfKeyExists "HKLM" "SOFTWARE\Microsoft\Windows Media" "Format"
Pop $R0
Or....
I don't have the reg key you give in my registry.
If you need to get the reg *value*, read the NSIS docs for EnumRegValue and basically all you need to do is write another macro replacing EnumRegValue with EnumRegKey (hint: copy the macro IfKeyExists.)
I don't have the reg key you give in my registry.
If you need to get the reg *value*, read the NSIS docs for EnumRegValue and basically all you need to do is write another macro replacing EnumRegValue with EnumRegKey (hint: copy the macro IfKeyExists.)
Is it going to work like following.
;------------------------------------------------
Function checkForWMP
Push $R0
StrCpy $installWMP "no"
StrCpy $R0 0
Push $0
Goto search
search:
ClearErrors
ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows Media" "Format"
;ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows Media" "Format"
;EnumRegKey $0 HKLM "SOFTWARE\JavaSoft\Java Runtime Environment" $R0
IfErrors notfound
StrCpy $0 $0 3
StrCmp $0 "11" found
StrCmp $0 "" notfound
IntOp $R0 $R0 + 1
Goto search
notfound:
MessageBox MB_YESNO "You need a suitable Window Media Player to use this Software. Install one now?$\n\
Choosing No will abort the installation of the player." \
IDYES install \
IDNO noinstall
Goto done
install:
StrCpy $installWMP "yes"
MessageBox MB_OK "Window Media Player needs to be downloaded. Please establish a connection to$\n\
the Internet and then click on OK to continue."
NSISdl::download /TIMEOUT=30000 "http://www.myDigit.com/pcplayer/wmp11-windowsxp-x86-enu.exe" "$INSTDIR\wmp11-windowsxp-x86-enu.exe"
Pop $R0 ;Get the return value
StrCmp $R0 "success" done
MessageBox MB_OK "Download of Window Media Player failed: $R0$\nAborting installation..."
Quit
Goto done
noinstall:
Quit
found:
;MessageBox MB_OK "Found Window Media Player version: $javaVersion"
Goto done
done:
Pop $R0
FunctionEnd
;------------------------------------------------
Function checkForWMP
Push $R0
StrCpy $installWMP "no"
StrCpy $R0 0
Push $0
Goto search
search:
ClearErrors
ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows Media" "Format"
;ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows Media" "Format"
;EnumRegKey $0 HKLM "SOFTWARE\JavaSoft\Java Runtime Environment" $R0
IfErrors notfound
StrCpy $0 $0 3
StrCmp $0 "11" found
StrCmp $0 "" notfound
IntOp $R0 $R0 + 1
Goto search
notfound:
MessageBox MB_YESNO "You need a suitable Window Media Player to use this Software. Install one now?$\n\
Choosing No will abort the installation of the player." \
IDYES install \
IDNO noinstall
Goto done
install:
StrCpy $installWMP "yes"
MessageBox MB_OK "Window Media Player needs to be downloaded. Please establish a connection to$\n\
the Internet and then click on OK to continue."
NSISdl::download /TIMEOUT=30000 "http://www.myDigit.com/pcplayer/wmp11-windowsxp-x86-enu.exe" "$INSTDIR\wmp11-windowsxp-x86-enu.exe"
Pop $R0 ;Get the return value
StrCmp $R0 "success" done
MessageBox MB_OK "Download of Window Media Player failed: $R0$\nAborting installation..."
Quit
Goto done
noinstall:
Quit
found:
;MessageBox MB_OK "Found Window Media Player version: $javaVersion"
Goto done
done:
Pop $R0
FunctionEnd