Hello,
I am not sure this is the place to post but here it goes.
Info: VS 2005, .NET 2.0, vb.net
I need to change the value of a key in the registry to point to a
network drive for our Word templates.
I created a console app which will be called via a bat file. I can get
it to work on my pc, but as soon as I drop the exe on the server, it
fails.
Here is my code:
Sub Main()
WriteRegistry(Registry.CurrentUser,
"Software\Microsoft\Office\11.0\Common\General ", "Templates",
"G:\TEMPLATES")
End Sub
Private Sub WriteRegistry(ByVal ParentKey As RegistryKey, ByVal
SubKey As String, _
ByVal ValueName As String, ByVal Value As Object)
Dim Key As RegistryKey
Try
'Open the registry key.
Key = ParentKey.OpenSubKey(SubKey,True, WriteKey)
If Key Is Nothing Then 'if the key doesn't exist.
Key = ParentKey.CreateSubKey(SubKey)
End If
'Set the value.
'Key.SetValue(ValueName, Value)
Console.Write(Key.GetValue("Templates"))
Key.Close()
Console.WriteLine("Value: {0} for {1} is successfully
written.", Value, ValueName)
Catch e As Exception
Console.WriteLine("Error occurs in WriteRegistry. " &
e.Message)
End Try
End Sub
I obviously left out some details but this is the important part.
Any help would be hugely appreciated.
THanks,
Tony