File tree Expand file tree Collapse file tree 4 files changed +119
-5
lines changed Expand file tree Collapse file tree 4 files changed +119
-5
lines changed Original file line number Diff line number Diff line change
1
+ using System . Diagnostics ;
2
+
3
+ namespace StartManager ;
4
+
5
+ public class Application
6
+ {
7
+
8
+ public static void StartFileServer ( )
9
+ {
10
+ var name = "hfs.exe" ;
11
+ }
12
+
13
+ public static void StartClient ( )
14
+ {
15
+ var name = "ClientSample.exe" ;
16
+ }
17
+
18
+ public static void StartServer ( )
19
+ {
20
+ var name = "ServerSample.exe" ;
21
+ }
22
+
23
+ public static void StartUpgrade ( )
24
+ {
25
+ var name = "UpgradeSample.exe" ;
26
+ }
27
+
28
+ public static void Reset ( )
29
+ {
30
+ }
31
+
32
+ private static void Start ( string appName , string path )
33
+ {
34
+ Process [ ] runningProcesses = Process . GetProcessesByName ( appName ) ;
35
+ foreach ( var process in runningProcesses )
36
+ {
37
+ try
38
+ {
39
+ process . Kill ( ) ;
40
+ Console . WriteLine ( $ "已关闭进程: { process . ProcessName } ") ;
41
+ break ;
42
+ }
43
+ catch ( Exception ex )
44
+ {
45
+ Console . WriteLine ( $ "关闭进程时发生错误: { ex . Message } ") ;
46
+ }
47
+ }
48
+
49
+ try
50
+ {
51
+ // 启动进程
52
+ var appPath = Path . Combine ( path , appName ) ;
53
+ Process . Start ( appPath ) ;
54
+ Console . WriteLine ( $ "进程已启动, { appPath } .") ;
55
+ }
56
+ catch ( Exception ex )
57
+ {
58
+ Console . WriteLine ( $ "启动进程时发生错误: { ex . Message } ") ;
59
+ }
60
+ }
61
+ }
Original file line number Diff line number Diff line change
1
+ @ echo off
2
+ setlocal
3
+
4
+ set " processes = ClientSample.exe ServerSample.exe UpgradeSample.exe hfs.exe StartManager.exe"
5
+
6
+ for %%p in (%processes% ) do (
7
+ echo Checking for process %%p ...
8
+ tasklist /FI " IMAGENAME eq %%p " 2 > NUL | find /I " %%p " > NUL
9
+ if not errorlevel 1 (
10
+ echo Terminating process %%p ...
11
+ taskkill /F /IM %%p
12
+ ) else (
13
+ echo Process %%p not found.
14
+ )
15
+ )
16
+
17
+ echo Done.
18
+ endlocal
Original file line number Diff line number Diff line change
1
+ @ echo off
2
+ setlocal
3
+
4
+ REM Define the base directory
5
+ set BASE_DIR = %~dp0
6
+
7
+ REM Check if run directory exists and delete it if it does
8
+ if exist " %BASE_DIR% run" (
9
+ echo Deleting existing run directory...
10
+ rmdir /s /q " %BASE_DIR% run"
11
+ )
12
+
13
+ REM Create run directory and its subdirectories
14
+ mkdir " %BASE_DIR% run"
15
+ mkdir " %BASE_DIR% run\app"
16
+ mkdir " %BASE_DIR% run\files"
17
+ mkdir " %BASE_DIR% run\files\old"
18
+ mkdir " %BASE_DIR% run\files\new"
19
+ mkdir " %BASE_DIR% run\files\patch"
20
+
21
+ REM Copy files from Client, Server, Upgrade to app directory
22
+ xcopy " %BASE_DIR% Client\bin\Release\net8.0\*" " %BASE_DIR% run\app\" /s /e /y
23
+ xcopy " %BASE_DIR% Server\bin\Release\net8.0\*" " %BASE_DIR% run\app\" /s /e /y
24
+ xcopy " %BASE_DIR% Upgrade\bin\Release\net8.0\*" " %BASE_DIR% run\app\" /s /e /y
25
+
26
+ REM Create test.txt files with specified content
27
+ echo 123456 > " %BASE_DIR% run\files\old\test.txt"
28
+ echo 123456abcd > " %BASE_DIR% run\files\new\test.txt"
29
+ echo . > " %BASE_DIR% run\files\patch\test.txt"
30
+
31
+ echo Operation completed successfully.
32
+
33
+ endlocal
Original file line number Diff line number Diff line change 1
1
@ echo off
2
+
3
+ call " %~dp0 process.bat"
4
+
2
5
REM 保存初始目录
3
6
set InitialDir = %CD%
4
7
5
- echo Starting hfs.exe...
6
- start " " .\FileService\hfs.exe
7
- echo hfs.exe has been started.
8
-
8
+ cd /d %InitialDir%
9
9
echo Running Server.bat
10
10
call .\Server\build.bat
11
11
echo .\Server\build.bat completed
@@ -27,7 +27,9 @@ echo .\Client\build.bat completed
27
27
28
28
echo All scripts completed.
29
29
30
- REM 使用 timeout 命令进行2秒倒计时
30
+ call " %~dp0 resource.bat"
31
+
32
+ REM 使用 timeout 命令进行3秒倒计时
31
33
timeout /t 3 /nobreak > nul
32
34
33
35
cd /d %InitialDir%
You can’t perform that action at this time.
0 commit comments