فهرست منبع

fix(ShellOnly):只为可能出错的部分弹出提示

薄奚梦灵 1 سال پیش
والد
کامیت
0aabb69e16

+ 5 - 8
Plain Craft Launcher 2/Modules/Base/ModBase.vb

@@ -2333,14 +2333,11 @@ NextElement:
     Public Sub ShellOnly(FileName As String, Optional Arguments As String = "")
         FileName = ShortenPath(FileName)
         Using Program As New Process
-            Try
-                Program.StartInfo.Arguments = Arguments
-                Program.StartInfo.FileName = FileName
-                Log("[System] 执行外部命令:" & FileName & " " & Arguments)
-                Program.Start()
-            Catch ex As Exception
-                Log(ex, "执行外部命令失败", LogLevel.Msgbox)
-            End Try
+            Program.StartInfo.Arguments = Arguments
+            Program.StartInfo.FileName = FileName
+            Log("[System] 执行外部命令:" & FileName & " " & Arguments)
+            Program.Start()
+            
         End Using
     End Sub
     ''' <summary>

+ 4 - 0
Plain Craft Launcher 2/Modules/Minecraft/ModCrash.vb

@@ -857,6 +857,7 @@ NextStack:
             "确定", If(IsHandAnalyze OrElse DirectFile Is Nothing, "", "查看日志"), If(IsHandAnalyze, "", "导出错误报告"),
             Button2Action:=If(IsHandAnalyze OrElse DirectFile Is Nothing, Nothing,
             Sub()
+            Try
                 '弹窗选择:查看日志
                 If File.Exists(DirectFile.Value.Key) Then
                     ShellOnly(DirectFile.Value.Key)
@@ -865,6 +866,9 @@ NextStack:
                     WriteFile(FilePath, Join(DirectFile.Value.Value, vbCrLf))
                     ShellOnly(FilePath)
                 End If
+            Catch ex As Exception
+                Log(ex,"尝试打开文件失败",LogLevel.Hint)
+            End Try
             End Sub))
             Case 3
                 '弹窗选择:导出错误报告

+ 7 - 1
Plain Craft Launcher 2/Modules/Minecraft/ModModpack.vb

@@ -828,7 +828,13 @@ Retry:
                     Log("[Modpack] 找到压缩包中附带的启动器:" & Launcher)
                     If MyMsgBox($"整合包里似乎自带了启动器,是否换用它继续安装?{vbCrLf}即将打开:{Launcher}", "换用整合包启动器?", "换用", "不换用") = 1 Then
                         OpenExplorer(TargetFolder)
-                        ShellOnly(Launcher, "--wait") '要求等待已有的 PCL 退出
+                        Try
+                            ShellOnly(Launcher, "--wait") '要求等待已有的 PCL 退出
+                        Catch ex As Exception
+                            Log(ex,"打开文件失败",LogLevel.MsgBox)
+                        Finally
+                            Return
+                        End Try
                         Log("[Modpack] 为换用整合包中的启动器启动,强制结束程序")
                         FrmMain.EndProgram(False)
                         Return