Kaynağa Gözat

解决部分电脑上无法更新的问题

自动安装运行库不再在线下载
master
张剑 2 yıl önce
ebeveyn
işleme
9db98110f5

+ 3
- 3
XHWK.WKTool/App.config Dosyayı Görüntüle

@@ -5,12 +5,12 @@
5 5
   </startup>
6 6
   <appSettings>
7 7
     <!--0正式 1测试-->
8
-    <add key="IsDebug" value="0" />
8
+    <add key="IsDebug" value="1" />
9 9
     <!--参数是否加密 0不加密 1加密-->
10 10
     <add key="IsParameterEncryption" value="0" />
11 11
     <!--版本号-->
12
-    <add key="VersionCode" value="114" />
13
-    <add key="VersionName" value="3.2.5" />
12
+    <add key="VersionCode" value="115" />
13
+    <add key="VersionName" value="3.2.6" />
14 14
     <!--皮肤样式 0白 1蓝 2黑色 -->
15 15
     <add key="SkinStyle" value="0" />
16 16
     <!--是否输出视频记录日志:0否-->

+ 16
- 13
XHWK.WKTool/AppUpdateWin.xaml.cs Dosyayı Görüntüle

@@ -1,6 +1,7 @@
1 1
 using System;
2 2
 using System.Diagnostics;
3 3
 using System.IO;
4
+using System.Management;
4 5
 using System.Windows;
5 6
 using System.Windows.Input;
6 7
 
@@ -82,27 +83,29 @@ namespace XHWK.WKTool
82 83
             progress_sp.Visibility = Visibility.Collapsed;
83 84
             content_sv.Visibility = Visibility.Visible;
84 85
             button_bottom.Visibility = Visibility.Visible;
86
+
85 87
             try
86 88
             {
87
-                using (Process process = new Process())
89
+                using (var managementClass = new ManagementClass("Win32_Process"))
88 90
                 {
89
-                    process.StartInfo.FileName = filepath;
90
-                    process.StartInfo.CreateNoWindow = true;
91
-                    process.StartInfo.UseShellExecute = false;
92
-                    process.StartInfo.RedirectStandardOutput = true;
93
-                    process.StartInfo.RedirectStandardError = true;
94
-
95
-                    process.Start();
91
+                    var processInfo = new ManagementClass("Win32_ProcessStartup");
92
+                    processInfo.Properties["CreateFlags"].Value = 0x00000008;
93
+
94
+                    var inParameters = managementClass.GetMethodParameters("Create");
95
+                    inParameters["CommandLine"] = filepath;
96
+                    inParameters["ProcessStartupInformation"] = processInfo;
97
+
98
+                    var result = managementClass.InvokeMethod("Create", inParameters, null);
99
+                    if ((result != null) && ((uint)result.Properties["ReturnValue"].Value != 0))
100
+                    {
101
+                        Console.WriteLine("Process ID: {0}", result.Properties["ProcessId"].Value);
102
+                    }
96 103
                 }
97 104
             }
98 105
             catch (Exception)
99 106
             {
100 107
             }
101
-            Dispatcher.Invoke(new Action(() =>
102
-            {
103
-                Environment.Exit(0);
104
-            }));
105
-            Close();
108
+            Environment.Exit(0);
106 109
         }
107 110
 
108 111
         public void downloadError(int position, string msg)

+ 22
- 100
星火微课/星火微课-正式.iss Dosyayı Görüntüle

@@ -3,7 +3,7 @@
3 3
 
4 4
 #define MyAppName "星火微课"  
5 5
 #define MyAppDir "xhwk"
6
-#define MyAppVersion "3.2.5"
6
+#define MyAppVersion "3.2.6"
7 7
 #define MyAppPublisher "河南星火燎原软件科技有限公司"
8 8
 #define MyAppURL "http://www.xhkjedu.com/"
9 9
 #define MySourcePath "D:\Project\CSharp\xhwkclient\XHWK.WKTool\bin\x86\Debug\"
@@ -18,7 +18,6 @@
18 18
 AppId={{5869900A-3BE4-463E-B0A6-462AA7454AE2}
19 19
 AppName={#MyAppName}
20 20
 AppVersion={#MyAppVersion}
21
-;AppVerName={#MyAppName} {#MyAppVersion}
22 21
 AppPublisher={#MyAppPublisher}
23 22
 AppPublisherURL={#MyAppURL}
24 23
 AppSupportURL={#MyAppURL}
@@ -44,6 +43,8 @@ Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{
44 43
 Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: checkablealone; OnlyBelowVersion: 6.1; Check: not IsAdminInstallMode
45 44
 
46 45
 [Files]
46
+Source: "D:\Tools\runtime\vc_redist.x86.exe"; DestDir: "{app}\runtime"; Check: NeedInstallVC
47
+Source: "D:\Tools\runtime\NDP452-KB2901954-Web.exe"; DestDir: "{app}\runtime";
47 48
 Source: "{#MySourcePath}{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
48 49
 Source: "{#MySourcePath}*"; Excludes: "\Log\*,\Temp,\Data";DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
49 50
 
@@ -53,37 +54,28 @@ Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: de
53 54
 Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: quicklaunchicon
54 55
 
55 56
 [Run]
57
+Filename: "{app}\runtime\vc_redist.x86.exe"; Parameters: /q; WorkingDir: {app}; Flags: skipifdoesntexist; StatusMsg: "Install Microsoft Visual C++ Runtime ..."; Check: NeedInstallVC
58
+Filename: "{app}\runtime\NDP452-KB2901954-Web.exe"; WorkingDir: {app}; Flags: skipifdoesntexist; StatusMsg: "Install .Net Framework ..."; Check: NeedInstallDotNet
56 59
 Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
57 60
 
58 61
 [Code]  
59
-function CheckVC():boolean;
60
-var Path:string; 
61
-      ResultCode: Integer;  
62
+function NeedInstallVC(): Boolean;
62 63
 begin
64
+// 这里,不同版本运行环境对应的GUID不同
63 65
   if RegValueExists(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{01FAEC41-B3BC-44F4-B185-5E8475AEB855}', 'Version') 
64
-  or RegValueExists(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{77EB1EA9-8E1B-459D-8CDC-1984D0FF15B6}', 'Version') 
65
-  then  
66
-    begin  
67
-      Result := true;   
68
-    end  
69
-  else  
70
-  begin  
71
-    if MsgBox('系统检测到您没有安装VC++环境,是否立刻下载并安装?', mbConfirmation, MB_YESNO) = idYes then  
72
-      begin  
73
-        Path := ExpandConstant('{pf}/Internet Explorer/iexplore.exe');   
74
-        Exec(Path, 'https://xhkjedu.oss-cn-huhehaote.aliyuncs.com/runtime/vc_redist.x86.exe', '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode);   
75
-        MsgBox('请安装好VC++环境后,再运行本安装包程序!',mbInformation,MB_OK);   
76
-        Result := false;   
77
-      end  
78
-    else  
79
-      begin  
80
-        MsgBox('取消后请手动安装VC2015-2019环境!',mbInformation,MB_OK);   
81
-        Result := true;   
82
-      end;   
83
-  end;
66
+  or RegValueExists(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{77EB1EA9-8E1B-459D-8CDC-1984D0FF15B6}', 'Version')
67
+  or RegValueExists(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{5720EC03-F26F-40B7-980C-50B5D420B5DE}', 'Version')
68
+    then
69
+      begin
70
+        Result := false;
71
+      end
72
+    else
73
+      begin
74
+        Result := true;
75
+      end;
76
+  Result := true;
84 77
 end;
85 78
 
86
-
87 79
 function IsInstallDotNet(version: string; service: cardinal): boolean;
88 80
 var
89 81
     key, versionKey: string;
@@ -145,86 +137,16 @@ begin
145 137
 end;
146 138
 
147 139
 // 检查.Net是否安装
148
-function CheckDotNet : Boolean;
149
-var Path:string;   
150
-    ResultCode: Integer;   
140
+function NeedInstallDotNet : Boolean;
151 141
 begin  
152 142
   if IsInstallDotNet('v4.5.2', 0) then  
153 143
     begin  
154
-        Result := true; 
144
+        Result := false; 
155 145
     end  
156 146
   else  
157 147
     begin  
158
-      if MsgBox('系统检测到您没有安装.Net Framework4.5.2,是否立刻下载并安装?', mbConfirmation, MB_YESNO) = idYes then  
159
-        begin  
160
-          Path := ExpandConstant('{pf}/Internet Explorer/iexplore.exe');   
161
-          Exec(Path, 'https://xhkjedu.oss-cn-huhehaote.aliyuncs.com/runtime/NDP452-KB2901907-x86-x64-AllOS-ENU.exe', '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode);   
162
-          MsgBox('请安装好.Net Framework环境后,再运行本安装包程序!',mbInformation,MB_OK);   
163
-          Result := false;   
164
-        end  
165
-      else  
166
-        begin  
167
-          MsgBox('没有安装.Net Framework环境,无法运行程序,本安装程序即将退出!',mbInformation,MB_OK);   
168
-          Result := false;   
169
-        end;   
170
-    end;
171
-end;
172
-
173
-function InitializeSetup: Boolean;
174
-begin
175
-  Result := CheckDotNet();
176
-  Result := CheckVC();
177
-end;   
178
-
179
-
180
-// 自定义函数,判断软件是否运行,参数为需要判断的软件的exe名称
181
-function CheckSoftRun(strExeName: String): Boolean;
182
-// 变量定义
183
-var ErrorCode: Integer;
184
-var bRes: Boolean;
185
-var strFileContent: AnsiString;
186
-var strTmpPath: String;  // 临时目录
187
-var strTmpFile: String;  // 临时文件,保存查找软件数据结果
188
-var strCmdFind: String;  // 查找软件命令
189
-var strCmdKill: String;  // 终止软件命令
190
-begin
191
-  strTmpPath := GetTempDir();
192
-  strTmpFile := Format('%sfindSoftRes.txt', [strTmpPath]);
193
-  strCmdFind := Format('/c tasklist /nh|find /c /i "%s" > "%s"', [strExeName, strTmpFile]);
194
-  strCmdKill := Format('/c taskkill /f /t /im %s', [strExeName]);
195
-  bRes := ShellExec('open', ExpandConstant('{cmd}'), strCmdFind, '', SW_HIDE, ewWaitUntilTerminated, ErrorCode);
196
-  if bRes then begin
197
-      bRes := LoadStringFromFile(strTmpFile, strFileContent);
198
-      strFileContent := Trim(strFileContent);
199
-      if bRes then begin
200
-         if StrToInt(strFileContent) > 0 then begin
201
-            // 终止程序
202
-           ShellExec('open', ExpandConstant('{cmd}'), strCmdKill, '', SW_HIDE, ewNoWait, ErrorCode);
203
-           Result:= true;// 继续安装
204
-         end else begin
205
-            // 软件没在运行
206
-            Result:= true;
207
-         end;
208
-      end;
209
-  end;
210
-  Result :=true;
211
-end;
212
-
213
-// 开始页下一步时判断软件是否运行
214
-function NextButtonClick(CurPageID: Integer): Boolean;
215
-begin
216
-  if 1=CurPageID then begin
217
-      Result := CheckSoftRun('{#MyAppExeName}');
218
-  end 
219
-  else begin
220
-      Result:= true;
221
-   end;
222
-end;
223
-
224
-// 卸载时关闭软件
225
-function InitializeUninstall(): Boolean;
226
-begin
227
-  Result := CheckSoftRun('{#MyAppExeName}');
148
+        Result := true; 
149
+    end 
228 150
 end;
229 151
 
230 152
 

+ 27
- 113
星火微课/星火微课-测试.iss Dosyayı Görüntüle

@@ -1,9 +1,9 @@
1 1
 ; 脚本由 Inno Setup 脚本向导 生成!
2 2
 ; 有关创建 Inno Setup 脚本文件的详细资料请查阅帮助文档!
3 3
 
4
-#define MyAppName "星火微课"  
5
-#define MyAppDir "xhwk"
6
-#define MyAppVersion "3.2.0"
4
+#define MyAppName "星火微课测试版"  
5
+#define MyAppDir "xhwk_test"
6
+#define MyAppVersion "3.2.6"
7 7
 #define MyAppPublisher "河南星火燎原软件科技有限公司"
8 8
 #define MyAppURL "http://www.xhkjedu.com/"
9 9
 #define MySourcePath "D:\Project\CSharp\xhwkclient\XHWK.WKTool\bin\x86\Debug\"
@@ -15,10 +15,9 @@
15 15
 ; 注: AppId的值为单独标识该应用程序。
16 16
 ; 不要为其他安装程序使用相同的AppId值。
17 17
 ; (若要生成新的 GUID,可在菜单中点击 "工具|生成 GUID"。)
18
-AppId={{5869900A-3BE4-463E-B0A6-462AA7454AE2}
18
+AppId={{B0C27451-3A3D-4819-9277-8C53517FA787}
19 19
 AppName={#MyAppName}
20 20
 AppVersion={#MyAppVersion}
21
-;AppVerName={#MyAppName} {#MyAppVersion}
22 21
 AppPublisher={#MyAppPublisher}
23 22
 AppPublisherURL={#MyAppURL}
24 23
 AppSupportURL={#MyAppURL}
@@ -44,8 +43,10 @@ Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{
44 43
 Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: checkablealone; OnlyBelowVersion: 6.1; Check: not IsAdminInstallMode
45 44
 
46 45
 [Files]
46
+Source: "D:\Tools\runtime\vc_redist.x86.exe"; DestDir: "{app}\runtime"; Check: NeedInstallVC
47
+Source: "D:\Tools\runtime\NDP452-KB2901954-Web.exe"; DestDir: "{app}\runtime";
47 48
 Source: "{#MySourcePath}{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
48
-Source: "{#MySourcePath}*"; Excludes: "ffmpeg.exe,\Log\*,\Temp,\Data";DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
49
+Source: "{#MySourcePath}*"; Excludes: "\Log\*,\Temp,\Data";DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
49 50
 
50 51
 [Icons]
51 52
 Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
@@ -53,92 +54,28 @@ Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: de
53 54
 Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: quicklaunchicon
54 55
 
55 56
 [Run]
57
+Filename: "{app}\runtime\vc_redist.x86.exe"; Parameters: /q; WorkingDir: {app}; Flags: skipifdoesntexist; StatusMsg: "Install Microsoft Visual C++ Runtime ..."; Check: NeedInstallVC
58
+Filename: "{app}\runtime\NDP452-KB2901954-Web.exe"; WorkingDir: {app}; Flags: skipifdoesntexist; StatusMsg: "Install .Net Framework ..."; Check: NeedInstallDotNet
56 59
 Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
57 60
 
58 61
 [Code]  
59
-// 自定义函数,判断软件是否运行,参数为需要判断的软件的exe名称
60
-function CheckSoftRun(strExeName: String): Boolean;
61
-// 变量定义
62
-var ErrorCode: Integer;
63
-var bRes: Boolean;
64
-var strFileContent: AnsiString;
65
-var strTmpPath: String;  // 临时目录
66
-var strTmpFile: String;  // 临时文件,保存查找软件数据结果
67
-var strCmdFind: String;  // 查找软件命令
68
-var strCmdKill: String;  // 终止软件命令
69
-begin
70
-  strTmpPath := GetTempDir();
71
-  strTmpFile := Format('%sfindSoftRes.txt', [strTmpPath]);
72
-  strCmdFind := Format('/c tasklist /nh|find /c /i "%s" > "%s"', [strExeName, strTmpFile]);
73
-  strCmdKill := Format('/c taskkill /f /t /im %s', [strExeName]);
74
-  bRes := ShellExec('open', ExpandConstant('{cmd}'), strCmdFind, '', SW_HIDE, ewWaitUntilTerminated, ErrorCode);
75
-  if bRes then begin
76
-      bRes := LoadStringFromFile(strTmpFile, strFileContent);
77
-      strFileContent := Trim(strFileContent);
78
-      if bRes then begin
79
-         if StrToInt(strFileContent) > 0 then begin
80
-            if MsgBox(ExpandConstant('{cm:checkSoftTip}'), mbConfirmation, MB_OKCANCEL) = IDOK then begin
81
-             // 终止程序
82
-             ShellExec('open', ExpandConstant('{cmd}'), strCmdKill, '', SW_HIDE, ewNoWait, ErrorCode);
83
-             Result:= true;// 继续安装
84
-            end else begin
85
-             Result:= false;// 安装程序退出
86
-             Exit;
87
-            end;
88
-         end else begin
89
-            // 软件没在运行
90
-            Result:= true;
91
-            Exit;
92
-         end;
93
-      end;
94
-  end;
95
-  Result :=true;
96
-end;
97
-
98
-// 开始页下一步时判断软件是否运行
99
-function NextButtonClick(CurPageID: Integer): Boolean;
100
-begin
101
-  if 1=CurPageID then begin
102
-      Result := CheckSoftRun('{#MyAppExeName}');
103
-      Exit;
104
-  end; 
105
-  Result:= true;
106
-end;
107
-
108
-// 卸载时关闭软件
109
-function InitializeUninstall(): Boolean;
110
-begin
111
-  Result := CheckSoftRun('{#MyAppExeName}');
112
-end;
113
-
114
-function CheckVC():boolean;
115
-var Path:string; 
116
-      ResultCode: Integer;  
62
+function NeedInstallVC(): Boolean;
117 63
 begin
64
+// 这里,不同版本运行环境对应的GUID不同
118 65
   if RegValueExists(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{01FAEC41-B3BC-44F4-B185-5E8475AEB855}', 'Version') 
119
-  or RegValueExists(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{77EB1EA9-8E1B-459D-8CDC-1984D0FF15B6}', 'Version') 
120
-  then  
121
-    begin  
122
-      Result := true;   
123
-    end  
124
-  else  
125
-  begin  
126
-    if MsgBox('系统检测到您没有安装VC++环境,是否立刻下载并安装?', mbConfirmation, MB_YESNO) = idYes then  
127
-      begin  
128
-        Path := ExpandConstant('{pf}/Internet Explorer/iexplore.exe');   
129
-        Exec(Path, 'https://xhkjedu.oss-cn-huhehaote.aliyuncs.com/runtime/vc_redist.x86.exe', '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode);   
130
-        MsgBox('请安装好VC++环境后,再运行本安装包程序!',mbInformation,MB_OK);   
131
-        Result := false;   
132
-      end  
133
-    else  
134
-      begin  
135
-        MsgBox('取消后请手动安装VC2015-2019环境!',mbInformation,MB_OK);   
136
-        Result := true;   
137
-      end;   
138
-  end;
66
+  or RegValueExists(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{77EB1EA9-8E1B-459D-8CDC-1984D0FF15B6}', 'Version')
67
+  or RegValueExists(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{5720EC03-F26F-40B7-980C-50B5D420B5DE}', 'Version')
68
+    then
69
+      begin
70
+        Result := false;
71
+      end
72
+    else
73
+      begin
74
+        Result := true;
75
+      end;
76
+  Result := true;
139 77
 end;
140 78
 
141
-
142 79
 function IsInstallDotNet(version: string; service: cardinal): boolean;
143 80
 var
144 81
     key, versionKey: string;
@@ -200,37 +137,14 @@ begin
200 137
 end;
201 138
 
202 139
 // 检查.Net是否安装
203
-function CheckDotNet : Boolean;
204
-var Path:string;   
205
-    ResultCode: Integer;   
140
+function NeedInstallDotNet : Boolean;
206 141
 begin  
207 142
   if IsInstallDotNet('v4.5.2', 0) then  
208 143
     begin  
209
-        Result := true; 
144
+        Result := false; 
210 145
     end  
211 146
   else  
212 147
     begin  
213
-      if MsgBox('系统检测到您没有安装.Net Framework4.5.2,是否立刻下载并安装?', mbConfirmation, MB_YESNO) = idYes then  
214
-        begin  
215
-          Path := ExpandConstant('{pf}/Internet Explorer/iexplore.exe');   
216
-          Exec(Path, 'https://xhkjedu.oss-cn-huhehaote.aliyuncs.com/runtime/NDP452-KB2901907-x86-x64-AllOS-ENU.exe', '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode);   
217
-          MsgBox('请安装好.Net Framework环境后,再运行本安装包程序!',mbInformation,MB_OK);   
218
-          Result := false;   
219
-        end  
220
-      else  
221
-        begin  
222
-          MsgBox('没有安装.Net Framework环境,无法运行程序,本安装程序即将退出!',mbInformation,MB_OK);   
223
-          Result := false;   
224
-        end;   
225
-    end;
226
-end;
227
-
228
-function InitializeSetup: Boolean;
229
-begin
230
-  Result := CheckDotNet();
231
-  Result := CheckVC();
232
-end; 
233
-
234
-
235
-[CustomMessages]
236
-chinesesimp.checkSoftTip=安装程序检测到将安装的软件正在运行!%n%n点击"确定"终止软件后继续操作,否则点击"取消"。
148
+        Result := true; 
149
+    end 
150
+end;

Loading…
İptal
Kaydet