Hi,
Im relatively new to .NET and am developing an Application for Windows Vista. Im running into a couple of issues with the Application when its trying to do 2 things - Copy a file, or Set a Registry Key Value. When Im running VS2005 both these 2 functions work no problem, but I would assume that this is because I run VS2005 as an Administrator. My Application wont be able to run as an Administrator I dont think, because I will be running the Application from boot up as a shell.
For the file copy, Im using a straightforward File.Copy, e.g.:
This raises the following error:
When I try to Set a Registry value, I was trying to look for the permission to do it with code, but its not working:
When I run this I get:
Im relatively new to .NET and am developing an Application for Windows Vista. Im running into a couple of issues with the Application when its trying to do 2 things - Copy a file, or Set a Registry Key Value. When Im running VS2005 both these 2 functions work no problem, but I would assume that this is because I run VS2005 as an Administrator. My Application wont be able to run as an Administrator I dont think, because I will be running the Application from boot up as a shell.
For the file copy, Im using a straightforward File.Copy, e.g.:
Code:
Dim strPathFrom As String = "C:\FolderName\Filename.txt"
Dim strPathTo As String = "C:\Filename.txt"
File.Copy(strPathFrom, strPathTo, True)
Access to path "C:\Filename.txt" is denied
When I try to Set a Registry value, I was trying to look for the permission to do it with code, but its not working:
Code:
Imports System.Security.Permissions
<Assembly: RegistryPermissionAttribute( _
SecurityAction.RequestMinimum, ViewAndModify:="HKEY_LOCAL_MACHINE")>
Public Class Reset
Private Sub SetRegistry
My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "Shell", "C:\MyProgram.exe")
End Sub
End Class
Attempted to perform an unauthorized operation