NSIS InstallDir in Vista / XP - windows-vista

I created installer via NSIS. "c:\program files\myapp" is default folder for my application. But I need another default folder (for example c:\users\\AppData\myapp) in Windows Vista.
I found lot of Functions to determine Windows version, but I cannot call them before defining InstallDir variable. Any ideas how to do it?

You can set $instdir in .OnInit, or use MultiUser.nsh

Related

How do I find System32 directory in Electron?

I understand one should not just assume c:\windows\system32 is where system32 will be located but that there's a way to query Windows for it's location. My goal is to find the directory where I can copy a .scr (screensaver) to so that Windows finds it.
How do I do that? Specifically, how do I do that from an Electron app?
There are 2 system provided environment variables you can use. I have Windows 10
SystemRoot=C:\WINDOWS and
windir=C:\WINDOWS
So System32 would be
%SystemRoot%\System32 or
%windir%\System32

Register comdlg32.dll gets Regsvr32: DllRegisterServer entry point was not found

I have Windows 7, 64-bit.
I'm trying to register a .dll (comdlg32.dll) using regsvr32. But I get an error that says the dll is read but the DLLRegistryServer entry point is not found.
I have run the command under both System32 and SysWOW64 and I have run my commands with "Run As Administrator".
My old MSComDlg.CommonDialog component is no longer working with 64-bit.
comdlg32.dll is not a COM DLL and cannot be registered.
One way to confirm this for yourself is to run this command:
dumpbin /exports comdlg32.dll
You'll see that comdlg32.dll doesn't contain a DllRegisterServer method. Hence RegSvr32.exe won't work.
That's your answer.
ComDlg32.dll is a a system component. (exists in both c:\windows\system32 and c:\windows\syswow64) Trying to replace it or override any registration with an older version could corrupt the rest of Windows.
I can help more, but I need to know what MSComDlg.CommonDialog is. What does it do and how is it supposed to work? And what version of ComDlg32.dll are you trying to register (and where did you get it)?
comdlg32.dll is not really a COM dll (you can't register it).
What you need is comdlg32.ocx which contains the MSComDlg.CommonDialog COM class (and indeed relies on comdlg32.dll to work). Once you get ahold on a comdlg32.ocx, then you will be able to do regsvr32 comdlg32.ocx.
Registering DLL for Fundsite
Outdated or missing comdlg32.ocx runtime library can be the problem of causing this error.
Make sure comdlg32.ocx file is not corrupted otherwise Download the File comdlg32.ocx (~60 Kb Zip).
Download the file and extract the comdlg32.ocx to your the Windows\System32 folder or Windows\SysWOW64. In my case i started with Windows\System32 but it didn’t work at my end, so I again saved in Windows\SysWOW64.
Type following command from Start, Run dialog:“c:\windows>System32\regsvr32 Comdlg32.ocx “ or “c:\windows>SysWOW64\regsvr32 Comdlg32.ocx ”
Now Comdlg.ocx File is register and next step is to register the DLL
Copy the Fundsite.Text.Encoding. dll into .Net Framework folder for 64bit on below path
C:\Windows\Microsoft.NET\Framework64\v2.0.50727
Then on command prompt and go to directory C:\Windows\Microsoft.NET\Framework64\v2.0.50727 and then run the following command as shown below.
This will register the dll successfully.
C:\Windows\Microsoft.net\framework64\v2.0.50727>regasm "Dll Name".dll
Have you unistalled your Internet Explorer?
I did, and I had the same issues, if so, you have to:
Reactivate IE (Control Panel -- Programs and Features -- Turn Windows features on or off).
restarting the computer
(important!) running Windows Update to get all available updates for Microsoft Explorer
restarting the computer (again)
Finally it works!
I have faced the same issue with COMDLG32.OCX and MSFLXGRD.OCX in Windows 10 and Visual Studio 2010. It's an MFC application.
Then I downloaded its zip file from the google after extracting copy them at following paths:
C:\Windows\System32 (*For 32-bit machine*)
C:\Windows\SysWOW64 (*For 64-bit machine*)
Then run Command Prompt as an Administrator then run the following commands:
For Windows 64-bit systems c:\windows\SysWOW64\ regsvr32 comdlg32.ocx
c:\windows\SysWOW64\regsvr32 msflxgrd.ocx (My machine is 64-bit configuration)
For Windows 32-bit systems c:\windows\System32\ regsvr32 comdlg32.ocx
c:\windows\System32\regsvr32 msflxgrd.ocx
On successfully updation of the above cmds it shows succeed message.
Information about missing entry point error installing legacy VB6 compiled applications on Windows 10 which I hope could be useful to someone.
Missing OCX files can be found in the "OS\System folder" of the Visual Basic 6.0 installer package.
Today I copied the relevant OCX file (from our network) to the local computer
And then I typed the commands below, as administrator, which normally work to register it.
cd \windows\syswow64
regsvr32.exe /u mscomctl.ocx
regsvr32.exe /i mscomctl.ocx
(add the path to the locally copied file for the /i command)
However today I got errors from both these regsvr32.exe commands.
The second error was giving the DllImport missing entry point error which is similar to the error mentioned by the original poster.
To resolve, one of the things I tried was leaving out the switch -
regsvr32.exe mscomctl.ocx
To my surprise it then said it was successful.
To confirm, the application started up properly afterwards.
SOLUTION OF Regsvr32: DllRegisterServer entry point was not found,
Go to systemdrive(generally c:)\system32 and search file "Regsvr32.exe"
Right click and click in properties and go to security tab and click in advanced button.
Click in owner tab and click edit and select administrators and click ok.
Click in permissions
Click in change permissions.
Choose administrators and click edit and put tick on full control and click ok.
Similarly, choose SYSTEM and edit and put tick on full control and click ok and click in other dialog box which are opened.
Now .dll files can be registered and error don't come, you should re-install any software whose dll files was not registered during installation.
I also had the similar problem while registering myinfo.dll file in windows 7. Following work for me:
Create a short cut on your desktop
C:\Windows\System32\regsvr32.exe c:\windows\system32\myinfo.dll
right click on the short cut just created and select as Run as administrator.

InstallScript and registry

I have two .reg files, the difference between them is only in Key which depends on the version of Windows.
My registry file for Windows x86:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\NGG]
#="URL:NGG Protocol"
"URL Protocol"=""
[HKEY_CLASSES_ROOT\NGG\DefaultIcon]
#="C:\\wpf.exe"
"Test"="ika"
[HKEY_CLASSES_ROOT\NGG\Shell]
[HKEY_CLASSES_ROOT\NGG\Shell\Open]
[HKEY_CLASSES_ROOT\NGG\Shell\Open\command]
#="\"C:\\Program Files\\NGG\\start.exe\" \"%1\""
The difference in Windows x64:
#="\"C:\\Program Files(x86)\\NGG\\start.exe\" \"%1\""
How can I make an install script (InstallShield MSI) which checks the Windows version and then uses this current registry file.
Please help.
I would avoid using .reg files for this. Instead use InstallShield's and/or Windows Installer's support for variable values in the registry, and specify either "[ProgramFilesFolder]NGG\start.exe" "%1" in an MSI-based installation or "<PROGRAMFILES>\NGG\start.exe" "%1" in InstallScript based installation as the value in the Registry view.
(Or possibly go even more specific by using Verb support in an MSI-based project. Or reference something like "[#start.exe]" "%1" for your path, assuming you install that executable with a filekey of start.exe - see Formatted for details.)

MSI Error - Failure of regsvr32 custom action

Brief
I have an installation package (MSI based) which attempts to register a dll file for use as a Windows Explorer Bar (Internet Explorer Toolbar).
The custom action is defined as follows:
[SystemFolder]\regsvr32.exe /s "pathtodllhere"
The error
The regsvr32 custom action does not work on Windows XP 64-bit.
Output from MSI log:
CustomAction SystemFolder_2 returned actual error code 5. Error
1722. There is a problem with this Windows Installer package. A program run as part of the setup did not finish as expected. Action SystemFolder_2,
location: C:\Windows\SysWOW64\, command: regsvr32.exe /s "C:\Program
Files (x86)\Test Install\test.dll"
MSI (s) (10:F4): Product: Test Install -- Error 1722. There is a
problem with this Windows Installer package. A program run as part of
the setup did not finish as expected. Action SystemFolder_2, location:
C:\Windows\SysWOW64\, command: regsvr32.exe /s "C:\Program Files
(x86)\Test Install\test.dll"
A brief run-down of my tests/thoughts thus-far:
Custom action is in the "InstallFinalize" section, it is therefore run ONLY when the files have been dropped onto the hard drive.
Dll file is not corrupt and is valid.
Regsvr32 custom action works fine (and MSI installation) on: Windows 7 32-bit and Windows XP 32-bit.
Regsvr32 32-bit version is executed during 64-bit install (as it should).
Regsvr32 fails with error code 5, i.e. ERROR_ACCESS_DENIED.
Solutions and Musings
Self-registration - Not using regsvr32 and manually place the registry keys using my MSI Installer.
The dll is a Delphi COM dll which uses the TRegistry component to register itself. Again, I can't think of a reason why this wouldn't work as it is merely a wrapper, but just a thought.
Hopefully I have shown my research here and don't waste anyone's time!
The best practise solution (as you've alluded to) is to extract the registry entries from the component and write them to the registry using the msi.
Background
Regsvr32 requires admin rights and elevated privilege confirmation to register COM components under 64-bit Windows 7 but msiexec doesn't know to request elevated privileges for the custom action.
You can test this requirement by using "Open with..." to run C:\Windows\SysWOW64\regsvr32.exe on the component (which will fail). Whereas if you create a batch file for the registration and then "Run as Administrator" the component will register successfully.

How to implement check for program files folder in a windows installer

I have a VSTO setup project as per 1.
This site mentions that I do not need to implement security if I install the program in the Program files folder; but it does not explain how to implement this in a setup project (as custom actions, etc.)
Notes:
Need to be able to detect C:\Program Files\ under 32-bit systems or C:\Program FIles (x86)\ under x64 systems.
I am using VS2010 setup project.
A Visual Studio setup project already uses ProgramFilesFolder property for Application Folder. This property is resolved to "C:\Program Files" on 32-bit machines and to "C:\Program FIles (x86)" on 64-bit machines.
This method gets the required path in C# (For custom actions):
public static string GetProgramFilesPath()
{
Environment.SpecialFolder folder = Environment.Is64BitOperatingSystem? Environment.SpecialFolder.ProgramFiles: Environment.SpecialFolder.ProgramFilesX86;
return Environment.GetFolderPath(folder);
}
Note: Environment.Is64BitOperatingSystem is supported for .NET4.0 onwards. It uses any CPU option.

Resources