- NSIS Discussion
- Downloading and executing vcredist_x86.exe if necessary
Archive: Downloading and executing vcredist_x86.exe if necessary
Olaf van der Spek
26th November 2006 18:52 UTC
Downloading and executing vcredist_x86.exe if necessary
Hi,
I've got a VC8/2005 app that requires certain DLLs. Those can be installed with vcredist_x86.exe, but that exe is 2.5 mbyte.
Is there a way to check whether the DLLs are already installed and only download/install them if they're not?
Joel
26th November 2006 19:55 UTC
ifFileExists can help you..also check nsisdl
demiller9
26th November 2006 20:22 UTC
Olaf van der Spek - you may also need to download and install Windows Installer 3.1. I recently ran into a need to install the vcredist_x86 you mention, and it pops up an error ("1723") if the system doesn't have WI 3.1. And you'll need to set the switches to block the reboots that both of them want to do.
If you do search for the file(s), be aware that they install do different locations on different versions of the operating system. (That's why they were released as an executable instead of a simpler merge module.)
Don
Olaf van der Spek
26th November 2006 21:50 UTC
I don't like to hard-code paths. Maybe just trying to load the DLLs and checking whether that succeeds is better.
ranahimal
30th November 2006 12:38 UTC
Same problem!
I have same problem regarding vcredist_x86.exe.
I want to check and install it if necessary...
Adion
30th November 2006 15:22 UTC
I am also looking for a solution for this.
At first I tried to see if it would be possible to install the relevant files myself, but it seems very difficult to get them to register correctly.
So the vcredist_x86.exe also seems the only solution, but I can find 4 instances of msvcr80.dll on my computer, so I also don't know how to check for it being installed correctly.
I would asume though that one version of vcredist_x86.exe only installs one version of msvcr80.dll, so chances are that the location for that specific version will always be the same and can be checked for.
Anyone has an idea how to find out which version will be in there though?
I also didn't know about Windows Installer. Which version is installed on a standard windows xp installation?
demiller9
30th November 2006 16:03 UTC
I check the registry value HKLM Microsoft\Windows\CurrentVersion\Uninstall\{A49F249F-0C91-497F-86DF-B2585E8E76B7}\DisplayName to see if the redistributable package has been installed. If that value exists then I don't install either exe.
The switches for installing Windows Installer 3.1 would be "WindowsInstaller-KB893803-v2-x86.exe /quiet /norestart" and the switches for the redistributable "VCRedist_x86.exe /Q"
Don
Olaf van der Spek
30th November 2006 18:31 UTC
Originally posted by demiller9
I check the registry value HKLM Microsoft\Windows\CurrentVersion\Uninstall\{A49F249F-0C91-497F-86DF-B2585E8E76B7}\DisplayName to see if the redistributable package has been installed. If that value exists then I don't install either exe.
Does that work on XP x64? IA64? Vista?
demiller9
30th November 2006 18:51 UTC
Originally posted by Olaf van der Spek
Does that work on XP x64? IA64? Vista?
I don't have any of those OS so I can't answer your question.
Don
Joel
30th November 2006 18:54 UTC
I though that you were developers ;)
Don't you guys need MSVCP80.DLL and MSVCR80.DLL?
Find them, if isnot present....download the redist installer...
There are tons of examples of about this tasks...
Adion
30th November 2006 18:59 UTC
The problem is of course that you need to be sure of their location.
Just searching the complete system dir may be slow, and if the version is not correct I think it may even refuse to use that version, so I'm not sure if it is actually that simple :)
I would suppose that the registry check would work on other versions of windows as well, since it's always the x86 version you are installing. I'll try if I can check that tomorrow on Vista 64-bit.
Joel
30th November 2006 19:20 UTC
Originally posted by Adion
The problem is of course that you need to be sure of their location.
Just searching the complete system dir may be slow, and if the version is not correct I think it may even refuse to use that version, so I'm not sure if it is actually that simple :)
Not necesary, because you'll search for a specific file...
See codeproject
article.
It's so simple... I don't know wny the mambo-jumbo thingy :p
Adion
11th December 2006 14:32 UTC
The codeproject article also suggests to try and load a dll to see if the runtimes are already installed.
In the NSIS documentation I did find out how to call a function from a dll, but I have found nothing about error handling.
Does anyone know how to check if calling a function failed?
Red Wine
11th December 2006 17:44 UTC
Perhaps this code example would be helpful to detect if the runtimes are installed and check the required version.
OutFile "locate_msvcp80.exe"
ShowInstDetails show
!include "FileFunc.nsh"
!include "WordFunc.nsh"
!insertmacro Locate
!insertmacro VersionCompare
!define DLL_VER "8.00.50727.42"
Section
StrCpy $1 $WINDIR 3
${Locate} "$1" "/L=F /M=MSVCP80.DLL /S=0B" "LocateCallback"
IfErrors 0 +2
MessageBox MB_OK "Error"
MessageBox MB_OK '$$R0==$R0'
SectionEnd
Function LocateCallback
MoreInfo::GetProductVersion "$R9"
Pop $0
${VersionCompare} "$0" "${DLL_VER}" $R1
StrCmp $R1 0 0 new
messagebox mb_ok 'Found file at location $R9.$\r$\n \
Installed version is $0 required version is ${DLL_VER}. Versions are equal.' idok end
new:
StrCmp $R1 1 0 old
messagebox mb_ok 'Found file at location $R9.$\r$\n \
Installed version is $0 required version is ${DLL_VER}. Installed version is newer.' idok end
old:
StrCmp $R1 2 0 end
messagebox mb_ok 'Found file at location $R9.$\r$\n \
Installed version is $0 required version is ${DLL_VER}. Installed version is older.' idok end
end:
StrCpy "$0" StopLocate
Push "$0"
FunctionEnd
Adion
11th December 2006 18:12 UTC
Thanks, I just found the IfErrors function though, so I'm going to test if that works as expected first.
Adion
14th December 2006 21:27 UTC
IfErrors does not seem to catch errors when executing System::Call.
After checking the output, it seems you can check for an output by comparing the return value of the dll call.
Maybe this behaviour should be added to the documentation of the System::Call function?
This seemed to be working for me:
;Install runtime
System::Call 'mydll::aTestFunction() i .r0'
StrCmp $0 "error" 0 +3
File "vcredist_x86.exe"
Exec '"$INSTDIR\vcredist_x86.exe" /q'
azerger
8th January 2007 19:53 UTC
msvcr80.dll manifest stuff
Look at this example:
http://msdn2.microsoft.com/en-us/library/ms235291(VS.80).aspx
I'm trying the "Deploying Visual C++ library DLLs as private assemblies" example. So far with no luck though!
I have a win32 app and I just need these dll's, this is the correct way according to MS. Going the path of running the installer etc. is thwart with problems for the end user installations. If you can get this way to work, let me know.
Thanks,
Art
arif.ali.syed
4th March 2010 15:14 UTC
Originally posted by Red Wine
Perhaps this code example would be helpful to detect if the runtimes are installed and check the required version.
OutFile "locate_msvcp80.exe"
ShowInstDetails show
!include "FileFunc.nsh"
!include "WordFunc.nsh"
!insertmacro Locate
!insertmacro VersionCompare
!define DLL_VER "8.00.50727.42"
Section
StrCpy $1 $WINDIR 3
${Locate} "$1" "/L=F /M=MSVCP80.DLL /S=0B" "LocateCallback"
IfErrors 0 +2
MessageBox MB_OK "Error"
MessageBox MB_OK '$$R0==$R0'
SectionEnd
Function LocateCallback
MoreInfo::GetProductVersion "$R9"
Pop $0
${VersionCompare} "$0" "${DLL_VER}" $R1
StrCmp $R1 0 0 new
messagebox mb_ok 'Found file at location $R9.$\r$\n \
Installed version is $0 required version is ${DLL_VER}. Versions are equal.' idok end
new:
StrCmp $R1 1 0 old
messagebox mb_ok 'Found file at location $R9.$\r$\n \
Installed version is $0 required version is ${DLL_VER}. Installed version is newer.' idok end
old:
StrCmp $R1 2 0 end
messagebox mb_ok 'Found file at location $R9.$\r$\n \
Installed version is $0 required version is ${DLL_VER}. Installed version is older.' idok end
end:
StrCpy "$0" StopLocate
Push "$0"
FunctionEnd
While Compiling this code with latest version of MakeNSISW 2.3
I got following compilation error
!insertmacro: macro "LocateCall" requires 3 parameter(s), passed 5!
Apart from that I have another query ....
Say Microsoft has release 3 version of CRT for CRT8.
I know that if an application need v1 of CRT and if v2 or v3 is there that would work ....
but what if there is no version of CRT8 at all and
there is CRT9 ..will my app work with that ?
Was i clear? Say i have developed an app with VS 2008 Sp1...
now suppose in future if somebody tries my app... he/she doens;t have VC++ 2008 SP1 runtime but have VC++ 2010 or VC++ 2012 runtime .... will that support my app theoritically.
arif.ali.syed
5th March 2010 19:11 UTC
Can anybody help me compile this code
kalverson
14th November 2012 12:42 UTC
You could roll your own. Here is a helpful link I used.
http://blogs.msdn.com/b/astebner/arc...9/9384143.aspx