|
7 | 7 | ' |
8 | 8 | ' This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY |
9 | 9 |
|
| 10 | +Imports System.Runtime.InteropServices |
10 | 11 | Imports System.Security.Cryptography |
11 | 12 | Imports System.Text |
| 13 | +Imports System.Windows.Forms |
12 | 14 | Imports Microsoft.Win32 |
13 | 15 |
|
14 | 16 | Namespace OldParams |
@@ -80,7 +82,7 @@ Namespace OldParams |
80 | 82 |
|
81 | 83 | Public Shared ReadOnly Property RegistryKeyRoot As RegistryKey |
82 | 84 | Get |
83 | | - Return Registry.CurrentUser.OpenSubKey(REG_KEY_ROOT) |
| 85 | + Return Registry.CurrentUser.OpenSubKey(REG_KEY_ROOT, True) |
84 | 86 | End Get |
85 | 87 | End Property |
86 | 88 |
|
@@ -127,17 +129,25 @@ Namespace OldParams |
127 | 129 | ''' </summary> |
128 | 130 | ''' <param name="destinationPath">The location of the exported file.</param> |
129 | 131 | Public Shared Sub ExportParams(destinationPath As String) |
| 132 | + ' Duplicate file must be removed now otherwise reg.exe will hang waiting for an input to overwrite. |
| 133 | + If IO.File.Exists(destinationPath) Then |
| 134 | + ' Allow any exceptions to be passed up to caller. |
| 135 | + IO.File.Delete(destinationPath) |
| 136 | + End If |
| 137 | + |
130 | 138 | Dim regExpProcStartInfo As New ProcessStartInfo With { |
131 | 139 | .FileName = "reg.exe", |
132 | 140 | .UseShellExecute = False, |
133 | | - .RedirectStandardOutput = True, |
134 | 141 | .RedirectStandardError = True, |
135 | 142 | .CreateNoWindow = True, |
136 | 143 | .Arguments = "export """ & RegistryKeyRoot.Name & """ """ & destinationPath & """" |
137 | 144 | } |
138 | 145 |
|
139 | 146 | Dim proc = Process.Start(regExpProcStartInfo) |
140 | 147 | proc.WaitForExit() |
| 148 | + If proc.ExitCode = 1 Then |
| 149 | + Throw New InvalidOperationException("reg.exe encountered an error: " & proc.StandardError.ReadToEnd()) |
| 150 | + End If |
141 | 151 | End Sub |
142 | 152 |
|
143 | 153 | Public Shared Sub DeleteParams() |
|
0 commit comments