@@ -49,10 +49,12 @@ private string GetValue(EnvironmentVariablesElement environmentVariablesElement)
4949
5050 try {
5151 value = Environment . GetEnvironmentVariable ( environmentVariablesElement . Name , EnvironmentVariableTarget . Process ) ;
52- } catch ( ArgumentException ) {
53- throw new InvalidEnvironmentVariablesException ( "Failed to get the \" " + environmentVariablesElement . Name + "\" Environment Variable." ) ;
54- } catch ( SecurityException ) {
52+ } catch ( SecurityException ex ) {
53+ LogExceptionToLauncher ( ex ) ;
5554 throw new TaskRequiresElevationException ( "Getting the \" " + environmentVariablesElement . Name + "\" Environment Variable requires elevation." ) ;
55+ } catch ( Exception ex ) {
56+ LogExceptionToLauncher ( ex ) ;
57+ throw new InvalidEnvironmentVariablesException ( "Failed to get the \" " + environmentVariablesElement . Name + "\" Environment Variable." ) ;
5658 }
5759
5860 Regex regex = null ;
@@ -112,10 +114,12 @@ private string GetValue(EnvironmentVariablesElement environmentVariablesElement)
112114 try {
113115 // we need to find the compatibility layers so we can check later if the ones we want are already set
114116 compatibilityLayerValue = Environment . GetEnvironmentVariable ( __COMPAT_LAYER , EnvironmentVariableTarget . Process ) ;
115- } catch ( ArgumentException ) {
116- throw new InvalidEnvironmentVariablesException ( "Failed to get the \" " + __COMPAT_LAYER + "\" Environment Variable." ) ;
117- } catch ( SecurityException ) {
117+ } catch ( SecurityException ex ) {
118+ LogExceptionToLauncher ( ex ) ;
118119 throw new TaskRequiresElevationException ( "Getting the \" " + __COMPAT_LAYER + "\" Environment Variable requires elevation." ) ;
120+ } catch ( Exception ex ) {
121+ LogExceptionToLauncher ( ex ) ;
122+ throw new InvalidEnvironmentVariablesException ( "Failed to get the \" " + __COMPAT_LAYER + "\" Environment Variable." ) ;
119123 }
120124
121125 ProgressManager . CurrentGoal . Start ( modificationsElement . EnvironmentVariables . Count + modificationsElement . EnvironmentVariables . Count ) ;
@@ -146,10 +150,12 @@ private string GetValue(EnvironmentVariablesElement environmentVariablesElement)
146150 Find = environmentVariablesElement . Find ,
147151 Value = Environment . GetEnvironmentVariable ( environmentVariablesElement . Name , EnvironmentVariableTarget . Process )
148152 } ;
149- } catch ( ArgumentException ) {
150- throw new InvalidEnvironmentVariablesException ( "Failed to get the \" " + environmentVariablesElement . Name + "\" Environment Variable." ) ;
151- } catch ( SecurityException ) {
153+ } catch ( SecurityException ex ) {
154+ LogExceptionToLauncher ( ex ) ;
152155 throw new TaskRequiresElevationException ( "Getting the \" " + environmentVariablesElement . Name + "\" Environment Variable requires elevation." ) ;
156+ } catch ( Exception ex ) {
157+ LogExceptionToLauncher ( ex ) ;
158+ throw new InvalidEnvironmentVariablesException ( "Failed to get the \" " + environmentVariablesElement . Name + "\" Environment Variable." ) ;
153159 }
154160
155161 activeModificationsElement . EnvironmentVariables . Set ( activeEnvironmentVariablesElement ) ;
@@ -178,10 +184,12 @@ private string GetValue(EnvironmentVariablesElement environmentVariablesElement)
178184
179185 try {
180186 Environment . SetEnvironmentVariable ( environmentVariablesElement . Name , Environment . ExpandEnvironmentVariables ( value ) , EnvironmentVariableTarget . Process ) ;
181- } catch ( ArgumentException ) {
182- throw new InvalidEnvironmentVariablesException ( "Failed to set the \" " + environmentVariablesElement . Name + "\" Environment Variable." ) ;
183- } catch ( SecurityException ) {
187+ } catch ( SecurityException ex ) {
188+ LogExceptionToLauncher ( ex ) ;
184189 throw new TaskRequiresElevationException ( "Setting the \" " + environmentVariablesElement . Name + "\" Environment Variable requires elevation." ) ;
190+ } catch ( Exception ex ) {
191+ LogExceptionToLauncher ( ex ) ;
192+ throw new InvalidEnvironmentVariablesException ( "Failed to set the \" " + environmentVariablesElement . Name + "\" Environment Variable." ) ;
185193 }
186194
187195 // now throw up a restart in Web Browser Mode for Compatibility Settings
@@ -267,10 +275,12 @@ public void Deactivate(MODIFICATIONS_REVERT_METHOD modificationsRevertMethod = M
267275 // compatibility settings
268276 try {
269277 compatibilityLayerValue = Environment . GetEnvironmentVariable ( __COMPAT_LAYER , EnvironmentVariableTarget . Process ) ;
270- } catch ( ArgumentException ) {
271- throw new InvalidEnvironmentVariablesException ( "Failed to get the \" " + __COMPAT_LAYER + "\" Environment Variable." ) ;
272- } catch ( SecurityException ) {
278+ } catch ( SecurityException ex ) {
279+ LogExceptionToLauncher ( ex ) ;
273280 throw new TaskRequiresElevationException ( "Getting the \" " + __COMPAT_LAYER + "\" Environment Variable requires elevation." ) ;
281+ } catch ( Exception ex ) {
282+ LogExceptionToLauncher ( ex ) ;
283+ throw new InvalidEnvironmentVariablesException ( "Failed to get the \" " + __COMPAT_LAYER + "\" Environment Variable." ) ;
274284 }
275285
276286 // we get this right away here
@@ -307,10 +317,12 @@ public void Deactivate(MODIFICATIONS_REVERT_METHOD modificationsRevertMethod = M
307317 if ( modificationsRevertMethod == MODIFICATIONS_REVERT_METHOD . DELETE_ALL ) {
308318 try {
309319 Environment . SetEnvironmentVariable ( activeEnvironmentVariablesElement . Name , null , EnvironmentVariableTarget . Process ) ;
310- } catch ( ArgumentException ) {
311- throw new InvalidEnvironmentVariablesException ( "Failed to delete the \" " + environmentVariablesElement . Name + "\" Environment Variable." ) ;
312- } catch ( SecurityException ) {
320+ } catch ( SecurityException ex ) {
321+ LogExceptionToLauncher ( ex ) ;
313322 throw new TaskRequiresElevationException ( "Deleting the \" " + environmentVariablesElement . Name + "\" Environment Variable requires elevation." ) ;
323+ } catch ( Exception ex ) {
324+ LogExceptionToLauncher ( ex ) ;
325+ throw new InvalidEnvironmentVariablesException ( "Failed to delete the \" " + environmentVariablesElement . Name + "\" Environment Variable." ) ;
314326 }
315327 } else {
316328 // don't reset Compatibility Settings if we're restarting for Web Browser Mode
@@ -320,10 +332,12 @@ public void Deactivate(MODIFICATIONS_REVERT_METHOD modificationsRevertMethod = M
320332 || modeElement . Name != ModeElement . NAME . WEB_BROWSER ) {
321333 try {
322334 Environment . SetEnvironmentVariable ( activeEnvironmentVariablesElement . Name , activeEnvironmentVariablesElement . Value , EnvironmentVariableTarget . Process ) ;
323- } catch ( ArgumentException ) {
324- throw new InvalidEnvironmentVariablesException ( "Failed to set the \" " + environmentVariablesElement . Name + "\" Environment Variable." ) ;
325- } catch ( SecurityException ) {
335+ } catch ( SecurityException ex ) {
336+ LogExceptionToLauncher ( ex ) ;
326337 throw new TaskRequiresElevationException ( "Setting the \" " + environmentVariablesElement . Name + "\" Environment Variable requires elevation." ) ;
338+ } catch ( Exception ex ) {
339+ LogExceptionToLauncher ( ex ) ;
340+ throw new InvalidEnvironmentVariablesException ( "Failed to set the \" " + environmentVariablesElement . Name + "\" Environment Variable." ) ;
327341 }
328342 }
329343 }
0 commit comments