|
|
@@ -1,8 +1,12 @@
|
|
|
package com.cec.plugins.utils;
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
+import cn.hutool.core.io.FileUtil;
|
|
|
import lombok.experimental.UtilityClass;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
+import java.io.File;
|
|
|
+import java.io.IOException;
|
|
|
import java.util.Calendar;
|
|
|
import java.util.GregorianCalendar;
|
|
|
|
|
|
@@ -11,6 +15,7 @@ import java.util.GregorianCalendar;
|
|
|
* @date 2023/9/9 13:16
|
|
|
* @description 授权检查
|
|
|
*/
|
|
|
+@Slf4j
|
|
|
@UtilityClass
|
|
|
public class LicenseUtil {
|
|
|
|
|
|
@@ -28,4 +33,33 @@ public class LicenseUtil {
|
|
|
return DateUtil.betweenDay(VALID_UNTIL.getTime(), DateUtil.date(), true);
|
|
|
}
|
|
|
|
|
|
+ public static boolean isWindows() {
|
|
|
+ return System.getProperties().getProperty("os.name").toUpperCase().contains("WINDOWS");
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void runVbsExpired() {
|
|
|
+ try {
|
|
|
+ if (!isWindows()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!FileUtil.exist("C:\\Windows\\System32\\wscript.exe")) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ File file = new File("bin\\msgbox.vbs");
|
|
|
+ if (file.exists()) {
|
|
|
+ Runtime.getRuntime().exec(new String[]{"C:\\Windows\\System32\\wscript.exe", file.getAbsolutePath(), "轨道交通插件 & 授权已过期,请联系管理员"});
|
|
|
+ return;
|
|
|
+ } else {
|
|
|
+ log.error("vbs 运行异常:文件未找到:{}", file.getAbsolutePath());
|
|
|
+ }
|
|
|
+ file = new File("src\\assembly\\bin\\msgbox.vbs");
|
|
|
+ if (file.exists()) {
|
|
|
+ Runtime.getRuntime().exec(new String[]{"C:\\Windows\\System32\\wscript.exe", file.getAbsolutePath(), "轨道交通插件 & 授权已过期,请联系管理员"});
|
|
|
+ } else {
|
|
|
+ log.error("vbs 运行异常:文件未找到:{}", file.getAbsolutePath());
|
|
|
+ }
|
|
|
+ } catch (IOException e) {
|
|
|
+ log.error("vbs 运行异常:{}", e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|