Problems on Vista

D

Dhananjay

Hi All,
I have created one VSTo COM - addin for office 2007 in vb.net 2005. I
have seen that my code is not working if I access the
hkey_Classes_Root or hkey_local_machine through my code on windows
VISTA. My code is working fine on all OS except VISTA. I have access
to localmachine & classes_root since I can manipulate these keys
manually.
My code snippet for modifying HKEY_CLASSES_ROOT is as follows -
------------------------------------------------------------------------------------------------
Dim rk As Microsoft.Win32.RegistryKey
rk = Microsoft.Win32.Registry.ClassesRoot
With rk
.CreateSubKey(".asi",
Microsoft.Win32.RegistryKeyPermissionCheck.ReadWriteSubTree)
<-------------- Error starting from this line
.OpenSubKey(".asi", True).SetValue("", "ASI.Document",
Microsoft.Win32.RegistryValueKind.String)
.CreateSubKey("ASI.Document\shell\open\command")
End With

------------------------------------------------------------------------------------------------
My user account is Administrator.
Also my trace file (trace.txt) is not generated if my app's directory
is under "program files". If my app's directory is not in "Program
files", then creation of trace file is working fine!


Thanks,
Dhananjay
 
C

Cor Ligthert[MVP]

Dhananjay,

Probably you have changed this registry with VB. However is there any
relation to the VB lanugage or self?

It seems for me more a Vista newsgroup question as it works on XP and other
computers then it has nothing to do with VB or any other developping
language.

Cor
 
T

Tom Shelton

Dhananjay said:
Hi All,
I have created one VSTo COM - addin for office 2007 in vb.net 2005. I
have seen that my code is not working if I access the
hkey_Classes_Root or hkey_local_machine through my code on windows
VISTA. My code is working fine on all OS except VISTA. I have access
to localmachine & classes_root since I can manipulate these keys
manually.
My code snippet for modifying HKEY_CLASSES_ROOT is as follows -
------------------------------------------------------------------------------------------------
Dim rk As Microsoft.Win32.RegistryKey
rk = Microsoft.Win32.Registry.ClassesRoot
With rk
.CreateSubKey(".asi",
Microsoft.Win32.RegistryKeyPermissionCheck.ReadWriteSubTree)
<-------------- Error starting from this line

What is the error?
.OpenSubKey(".asi", True).SetValue("", "ASI.Document",
Microsoft.Win32.RegistryValueKind.String)
.CreateSubKey("ASI.Document\shell\open\command")
End With

------------------------------------------------------------------------------------------------
My user account is Administrator.
Also my trace file (trace.txt) is not generated if my app's directory
is under "program files". If my app's directory is not in "Program
files", then creation of trace file is working fine!

Apps on vista are not allowed to write to the Program Files directory. You
should be using System.Environment.GetFolderPath to get the application data
folder. That's where you should be writing to. Like this:

dim appDataPath as string = System.Environment.GetFolderPath
(System.Environment.SpecialFolder.ApplicationData)

Really, this is how it should have been all along - it's just that MS has
started enforcing it with Vista.
 
P

Phill W.

Dhananjay said:
I have seen that my code is not working if I access the
hkey_Classes_Root or hkey_local_machine through my code on windows
VISTA. My code is working fine on all OS except VISTA. I have access
to localmachine & classes_root since I can manipulate these keys
manually.

And do you get a User Access Control (UAC) Dialog when you start RegEdit?

"User" processes, i.e. any program that you can run without getting a
UAC dialog, /cannot/ update the Registry under HKLM or HKCR nor can they
write anywhere under Program Files, unless the program /happens/ to be
an Installer.

You need to create an Installer for your AddIn and run that on the
target machine(s), then your AddIn shouldn't have to touch the Registry.

Regards,
Phill W.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top