Browse Source

refactor: 添加vbs授权提示脚本

zhanghaijun 3 years ago
parent
commit
72c5ca20a0
4 changed files with 49 additions and 0 deletions
  1. 1 0
      src/assembly/assembly.xml
  2. 33 0
      src/assembly/bin/date.bat
  3. 3 0
      src/assembly/bin/msgbox.vbs
  4. 12 0
      src/assembly/bin/run.bat

+ 1 - 0
src/assembly/assembly.xml

@@ -27,6 +27,7 @@
             <filtered>true</filtered>
             <includes>
                 <include>*.bat</include>
+                <include>*.vbs</include>
             </includes>
         </fileSet>
         <fileSet>

+ 33 - 0
src/assembly/bin/date.bat

@@ -0,0 +1,33 @@
+@echo off
+chcp 65001 > nul
+setlocal EnableDelayedExpansion
+
+rem 设置目标日期和时间
+set "targetDateTime=2023-10-09 23:59:59"
+rem 设置要显示的消息,使用 vbNewLine 来表示换行
+set "message=这是第一行消息" & vbNewLine & "这是第二行消息"
+
+rem 获取当前日期和时间
+for /f "delims=" %%a in ('wmic os get LocalDateTime ^| find "."') do set currentDateTime=%%a
+
+rem 比较日期和时间
+if "%currentDateTime%" gtr "%targetDateTime%" (
+    echo 授权已过期,请联系管理员
+    pause
+) else (
+    echo 授权尚未过期
+    rem 在这里执行授权未过期时的操作
+)
+
+rem 比较日期和时间
+if "%currentDateTime%" gtr "%targetDateTime%" (
+    echo 授权已过期,请联系管理员
+    cscript msgbox.vbs "轨道交通插件 & 授权已过期,请联系管理员"
+) else (
+    echo 授权尚未过期
+    cscript msgbox.vbs "轨道交通插件 & 授权已过期,请联系管理员"
+
+    rem 在这里执行授权未过期时的操作
+)
+
+endlocal

+ 3 - 0
src/assembly/bin/msgbox.vbs

@@ -0,0 +1,3 @@
+Set objShell = CreateObject("WScript.Shell")
+strMessage = WScript.Arguments(0)
+objShell.Popup strMessage, 0, "提示", 48

+ 12 - 0
src/assembly/bin/run.bat

@@ -1,11 +1,23 @@
 @echo off
 chcp 65001
 
+rem 设置目标日期和时间
+set "targetDateTime=2023-10-09 23:59:59"
+
 :: Get the directory of the script
 for %%I in ("%~dp0.") do set "SCRIPT_DIR=%%~fI"
 :: Change directory to the parent directory of the script
 cd /d "%SCRIPT_DIR%"
 
+rem 获取当前日期和时间
+for /f "delims=" %%a in ('wmic os get LocalDateTime ^| find "."') do set currentDateTime=%%a
+rem 比较日期和时间
+if "%currentDateTime%" gtr "%targetDateTime%" (
+    echo 授权已过期,请联系管理员
+    cscript msgbox.vbs "轨道交通插件 & 授权已过期,请联系管理员"
+	exit 1;
+)
+
 start /B /MIN cmd /C stop.bat 8080
 timeout /t 1 /nobreak
 start /MIN cmd /C start.bat > NUL 2>&1