Create Registry Value In Local Machine Using C# - c#

I'm trying to save an install path to the registry so my windows service will know where my other application was installed.
I'm using visual studio's deployment to create a registry value in HKEY_CURRENT_USER, but my windows service which runs under LocalMachine doesn't have access to that. I then made the installer create a registry value in HKEY_LOCAL_MACHINE, but when I view the registry after the install it appears it never made the value. Any ideas?

Turns out that it was written to HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ instead of HKEY_LOCAL_MACHINE\SOFTWARE\ because I'm running 64 bit windows.

You dont need to make one of your own. The msi will actually set one for you, it can be found in
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{ProductGUID}\InstallLocation
EDIT
I have just had a look and it appears that it doesn't get set every time...

It's possible that you don't have the installer set to ask for privilege elevation, and that it's installing it in the per-user virtualized registry.
Check HKEY_CLASSES_ROOT\VirtualStore\Machine. If your key is there, you need to set your installer to ask for elevation.

Related

BarTender Error: Retrieving the COM class factory for component with CLSID in Asp.Net

I selected the BarTender from Com tab on preferences screen and add BarTender into my project.
when I execute the project with Ctrl+F5 on my local computer I can print the barcode smoothly.
But when I publish my project under wwwroot I get an error as follows,
Also I set the project platform “ x86 – x64 Any Cpu” but nothing was changed.
PS: I am giving the screenshots as links because of I have not enough points. Sorry for this
It's an EXE server, so it looks like you need to give Local Launch and Local Activation permissions to the COM Class for the identity that your web site is running under. You can do this with DCOMCnfg.exe. Have a look at the Application Pool identity and make sure it has the appropriate rights. A good way to test the problem is to set it to "EVERYONE". If that works then it's definately your problem, but DO NOT leave it set to "EVERYONE". Once you've proven this is the issue, you'll need to set the activation, launch and probably access permissions correctly.
This is due to the security settings on the library itself. I had the same issues with Excel & Illustrator COM's.
Even though this is Excel, this site will guide you through setting the security and permissions.
UPDATE:
If you can't find the library then it may be a 32 bit one; these don't always show up in 64 bit console (assuming you're running 64 bit..) - if so, you need to launch the 32 bit DCOMCONFIG. See bottom of the page here on how to launch 32 bit version.

How to get installed applications install folder(path) and uninstaller

Hello I need some way of finding all the insllaled applications on windows(I already found the names but i need the actual folder). Also I need the path to their uninstaller.
I'm trying to build an application that is similar with Advanced Uninstaller pro.
PS. I need to do this in C#.
I think you wont need the path to the installer, you have to get the UninstallString value for each installed application so you can excute it once wanted to be removed. All of them are available here : HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall (my case is 64bit system)
You can enumerate all apps from here by getting DisplayName value. Hope it helps

How does the InstallAllUsers option work?

I have a C# application, and a Visual Studio (2010) Setup Project with it. In my Setup Project, I am using InstallAllUsers = True. Additionally, my application needs to launch at Startup, so a shortcut is being added to the User's Startup Folder.
So I install my application as user Bob (from a share), and then I log off and log on as user Alice. Alice gets a dialogue that says:
The feature you are trying to use is on a network resource that is unavailable.
It provides the network path from which the MSI was installed. So, basically, it's looking for the MSI on a share that Alice doesn't have access to. This is repeatedly reproducible if Alice tries to manually launch the Startup link. However, Alice can directly launch the exe from the installation location, which works fine.
I don't fully understand why it is looking for an MSI, but I guess it makes sense that an application can not be completely installed by one user for another user, so the MSI is needed to complete the installation.
But if that is the case, then I don't understand why the MSI only seems to be required when launching from the Startup link, and not from the exe directly.
My question has several parts:
Is what I am experiencing expected behaviour for the InstallAllUsers option?
If so, how can I ensure that my application is fully installed for all users?
Is it necessary to copy the msi locally, and ensure that it does not get deleted before each user has had a chance to log on?
This is happening because the shortcuts are "advertised shortcuts" hence the greyed out target box.
More info here...
http://www.advancedinstaller.com/user-guide/advertised-shortcuts.html
When an advertised shortcut is launched it validates the checks
associated with the key resources. If any is missing it will fix it by
running the installation package and installing again all information
from the .msi file.
This is why its trying to run the msi.
You can turn off advertised shortcuts by reading this article...
DISABLEADVTSHORTCUTS=1 disables all shortcuts
If its an all users install, then the shortcut will probably want to reside in the all users start menu. Win 7: C:\ProgramData\Microsoft\Windows\Start Menu.
Eric, I would recommend taking a look at the shortcut file contents. You can do this by using Powershell, and there is a SO link to help you on your way:
Editing shortcut (.lnk) properties with Powershell

Access to the registry key is denied (ABCPdf)

I am trying out ABCPdf 8.1 and when using the AddImageUrl(...) method I get the following error:
Access to the registry key 'HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl' is denied.
I have looked in the registry and main\featurecontrol does not exist for CURRENT_USER so I cannot change permissions on it.
Has anyone experienced this before, or know of any solutions I could try?
Thanks in advance
Who is the CURRENT_USER? Assuming it's an ASP.NET application identity, have you tried loading its user profile?
Open up IIS Manager and navigate to the application pool for your site. In the Advanced Settings dialog, set Load User Profile to True.
Perhaps it's a problem between IE9 and ABCPDF.If this error comes by using AddHtml() or AddImageHtml() , I suggest you to change the Rendering Engine from MSHtml to Gecko.
theDoc.HtmlOptions.Engine = EngineType.Gecko;
http://www.websupergoo.com/support.htm
In my case, this solution solved my error.
If you know the specific key that ABCPDF is trying to add, and you don't want to change the app pool settings, you can set the appropriate key in HKEY_LOCAL_MACHINE. We had exactly that situation and knew that ABCPDF wanted to add the FEATURE_IVIEWOBJECTDRAW_DMLT9_WITH_GDI key. So we added the entries below to the registry. Note that the second key is specifically for 32-bit applications running on 64-bit Windows.
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_IVIEWOBJECTDRAW_DMLT9_WITH_GDI]
"w3wp.exe"=dword:00000001
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_IVIEWOBJECTDRAW_DMLT9_WITH_GDI]
"w3wp.exe"=dword:00000001
I'm not sure if this is the answer but if you are trying to access this programaticaly your executable should run as administrator while accessing it. If you are in debug mode run visual studio as administrator (right click and select "Run as administrator"

Access error in Windows 7

I am working on a windows appliciation in which i create a folder at runtime and save some xml files in the folder....
Every thing works fine in Windows XP but when i run this in Widows 7 / Vista i get the error saying Access to the path is denied..
i am creating the folder in C:\Programfiles\MyApplication\
Please help me in resolving this
Windows 7 (and Vista) set access permissions on the Program Files directories and will not allow a normal user to write to those directories.
Either your program has to be run by an administrator, or you can change the permissions on your app's Program Files entry, or save the data somewhere else.
It might be an idea to use the special folders .NET provides for this type of data. This should work:
Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + #"\AppName\test folder");
Then write your data to this folder.
Is your application running in the context of administrator?
Is visual studio running as administrator?
To do this right click VS and select run as administrator, to do it permanently, right click, propertys and select the run as admin check box.
When your debugging your app through VS, it will need the permissions, else the application its self will.
Its probably just a permissions based thing...
You can enable XP mode for an executable.
Please find the settings below
link text
Long time Windows XP developers should consider reading UAC,
http://en.wikipedia.org/wiki/User_Account_Control
It was first added in Windows Vista, and now becomes a central part of Windows family.
You SHOULDN'T write to Program Files. It's a bad habit and only installers should write there. What you "want" is bad for the whole ecosystem and just plain wrong. Don't do it.

Categories