tags:

views:

11

answers:

1

Hi I am using following code to add my application to StartUp of Windows. It works well in XP but gives error in Vista that you donot have permission to edit registty file.

Private Sub Forceps_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Dim regStartUp As RegistryKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True)

        'Dim value As String

        'value = regStartUp.GetValue("Myapp")

        'If value <> Application.ExecutablePath.ToString() Then

        'regStartUp.CreateSubKey("Myapp")
        'regStartUp.SetValue("Myapp", Application.ExecutablePath.ToString())

        '        End If

End Sub
A: 

This is caused by the User Account Control (UAC) feature in Vista. Admininstrators on Vista (and 7 and Server 2008 sometimes) run with a user token that is limited in privileges unless the application explicitly requests them.

Some links to read about UAC and how to configure your application.

http://en.wikipedia.org/wiki/User_Account_Control

http://technet.microsoft.com/en-us/library/cc709691(WS.10).aspx

http://bartdesmet.net/blogs/bart/archive/2006/10/28/Windows-Vista-2D00-Demand-UAC-elevation-for-an-application-by-adding-a-manifest-using-mt.exe.aspx

Adam Sills