Video Screencast Help
Search Video Help Close Back
to help
New in the Rewards Catalog: Vouchers for "Symantec Technical Specialist" and "Symantec Certified Specialist" exams.

Check if a DLL exist in SYSTEM 32 folder

Updated: 21 May 2010 | 6 comments
dmosic's picture
0 0 Votes
Login to vote

I've created a MSI packag by copying some files in a specified folder. It is necessary  to check if some DLL file already exist in SYSTEM32 folder.
What is the best way to do this and where can i place DLL  file which hat to be copied in case if not exist in SYSTEM32 folder.

It would be greate if i can to integrate MERGE MODULE.

Can anyone help me?

Many thanks.

discussion Filed Under:

Comments

EdT's picture
13
Jul
2009
0 Votes 0
Login to vote

Does the DLL file have to be a specific version?

What DLL are you trying to install?
Some DLL's in system32 are protected by Windows File Protection and cannot be replaced with a newer version from an MSI.

If the DLL is not protected, then you could just choose to install your DLL into System32 - MSI file versioning rules will install the file if there is no existing DLL present, and if there IS an existing DLL present, then the existing DLL will only be overwritten if you are installing a newer version.

This behaviour is identical regardless of whether your DLL is in a merge module or not.

Note also that Microsoft recommend that any files installed to the System32 folder should not be removed on uninstall. To achieve this, mark the component that installs your DLL as "Permanent".

If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.

dmosic's picture
14
Jul
2009
0 Votes 0
Login to vote

Check if a DLL exist in SYSTEM 32 folder

Before i'm going to copy file i have to check if files exist. The DLL file wich ii've to check are: comcat.dll;oleaut32.dll;comctl32.dll;msflxgrd.dll;comdlg32.dll
In this  case the version is not important. My big problem is, how to check if files exist and copy if not exist.

EdT's picture
14
Jul
2009
0 Votes 0
Login to vote

Why do you need to check if the files exist?

Windows Installer will only install the new files if the existing files are an older version or don't exist. So why do you need to test if they are there?  Just add the files to the install and let windows installer decide how to act.

If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.

dmosic's picture
15
Jul
2009
0 Votes 0
Login to vote
Eshwar's picture
17
Jul
2009
0 Votes 0
Login to vote

dmosic, Please do not forget

dmosic,
Please do not forget to mark the SOLUTION, if the comments really helped you getting your job done.

Thanks,
Eshwar

Thanks,
Eshwar

Munna's picture
20
Jul
2009
0 Votes 0
Login to vote

Try this

Hey,
 
If you have the option of using the VBScript, I have a simple script for that. Just you need to  copy the script to the folder containing the .dll files and from there you execute this.

Option Explicit 'all variables must be defined

Dim sWinDir, sSysDir, sScriptDir, sCmdLine, i
Dim sDocsAndSettings, colFolders, oFolder, objFolder
Dim oShell, oFSO

'*************************************************************************************************
' Get scripting objects needed throughout script.
Set oShell = CreateObject("WScript.Shell")
Set oFSO = CreateObject("Scripting.FileSystemObject")
'*************************************************************************************************
'Get key Windows, Windows/System32 and script directories.
sWinDir = oFSO.GetSpecialFolder(0).Path
If Right(sWinDir,1) <> "\" Then sWinDir = sWinDir & "\"
sSysDir = oFSO.GetSpecialFolder(1).Path
If Right(sSysDir,1) <> "\" Then sSysDir = sSysDir & "\"
sScriptDir = oFSO.GetParentFolderName(WScript.ScriptFullName)
If Right(sScriptDir,1) <> "\" Then sScriptDir = sScriptDir & "\"

'**************************************************************************************************
'Verify "files" are in same folder as script.

If Not oFSO.FileExists(sScriptDir & "comcat.dll") Then
MsgBox "Unable to locate " & sScriptDir & "comcat.dll", vbCritical, "Error!"
WScript.Quit (1)
End If

If Not oFSO.FileExists(sScriptDir & "oleaut32.dll") Then
MsgBox "Unable to locate " & sScriptDir & "oleaut32.dll", vbCritical, "Error!"
WScript.Quit (1)
End If

If Not oFSO.FileExists(sScriptDir & "comctl32.dll") Then
MsgBox "Unable to locate " & sScriptDir & "comctl32.dll", vbCritical, "Error!"
WScript.Quit (1)
End If

If Not oFSO.FileExists(sScriptDir & "msflxgrd.dll") Then
MsgBox "Unable to locate " & sScriptDir & "msflxgrd.dll", vbCritical, "Error!"
WScript.Quit (1)
End If
If Not oFSO.FileExists(sScriptDir & "comdlg32.dll") Then
MsgBox "Unable to locate " & sScriptDir & "comdlg32.dll", vbCritical, "Error!"
WScript.Quit (1)
End If

'***********************************************************************************************************
' Copy File if C:\WINDOWS\system32\ if they dont Exist.

If Not oFSO.FileExists(sSysDir & "comcat.dll") Then
oFSO.CopyFile sScriptDir & "comcat.dll", sSysDir, True
End If

If Not oFSO.FileExists(sSysDir & "oleaut32.dll") Then
oFSO.CopyFile sScriptDir & "oleaut32.dll", sSysDir, True
End If

If Not oFSO.FileExists(sSysDir & "comctl32.dll") Then
oFSO.CopyFile sScriptDir & "comctl32.dll", sSysDir, True
End If

If Not oFSO.FileExists(sSysDir & "msflxgrd.dll") Then
oFSO.CopyFile sScriptDir & "msflxgrd.dll", sSysDir, True
End If

If Not oFSO.FileExists(sSysDir & "msrdc20.ocx") Then
oFSO.CopyFile sScriptDir & "msrdc20.ocx", sSysDir, True
End If

If Not oFSO.FileExists(sSysDir & "comdlg32.dll") Then
oFSO.CopyFile sScriptDir & "comdlg32.dll", sSysDir, True
End If

'*******************************************End of the Script*************************************************

I hope this will help you.
Thanks,
Munna.