diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 835bb3b..549b753 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -241,7 +241,7 @@ jobs:
run: |
pnpm install
pnpm add @mihomo-party/sysproxy-darwin-${{ matrix.arch }}
- pnpm add -D electron@32.2.0
+ pnpm add -D electron@32.2.1
pnpm prepare --${{ matrix.arch }}
- name: Build
env:
diff --git a/src/main/sys/autoRun.ts b/src/main/sys/autoRun.ts
index f50267d..c834e89 100644
--- a/src/main/sys/autoRun.ts
+++ b/src/main/sys/autoRun.ts
@@ -1,4 +1,4 @@
-import { taskDir, exePath, homeDir } from '../utils/dirs'
+import { exePath, homeDir } from '../utils/dirs'
import { mkdir, readFile, rm, writeFile } from 'fs/promises'
import { exec } from 'child_process'
import { existsSync } from 'fs'
@@ -7,51 +7,6 @@ import path from 'path'
const appName = 'mihomo-party'
-const taskXml = `
-
-
- ${new Date().toISOString()}
- ${process.env.USERNAME}
-
-
-
- true
- PT3S
-
-
-
-
- InteractiveToken
- HighestAvailable
-
-
-
- IgnoreNew
- false
- false
- false
- true
- true
-
- false
- false
-
- true
- true
- false
- false
- false
- PT0S
- 7
-
-
-
- ${exePath()}
-
-
-
- `
-
export async function checkAutoRun(): Promise {
if (process.platform === 'win32') {
const execPromise = promisify(exec)
@@ -82,10 +37,8 @@ export async function checkAutoRun(): Promise {
export async function enableAutoRun(): Promise {
if (process.platform === 'win32') {
const execPromise = promisify(exec)
- const taskFilePath = path.join(taskDir(), `${appName}.xml`)
- await writeFile(taskFilePath, Buffer.from(`\ufeff${taskXml}`, 'utf-16le'))
await execPromise(
- `C:\\\\Windows\\System32\\schtasks.exe /create /tn "${appName}" /xml "${taskFilePath}" /f`
+ `C:\\\\Windows\\System32\\schtasks.exe /create /tn "${appName}" /tr "${exePath()}" /sc onlogon /delay 0000:03 /rl HIGHEST /it /f`
)
}
if (process.platform === 'darwin') {
diff --git a/src/main/sys/misc.ts b/src/main/sys/misc.ts
index f79f7ae..0239cab 100644
--- a/src/main/sys/misc.ts
+++ b/src/main/sys/misc.ts
@@ -12,7 +12,7 @@ import {
resourcesFilesDir,
taskDir
} from '../utils/dirs'
-import { copyFileSync, writeFileSync } from 'fs'
+import { copyFileSync } from 'fs'
export function getFilePath(ext: string[]): string[] | undefined {
return dialog.showOpenDialogSync({
@@ -64,55 +64,12 @@ export function setNativeTheme(theme: 'system' | 'light' | 'dark'): void {
nativeTheme.themeSource = theme
}
-const elevateTaskXml = `
-
-
- ${new Date().toISOString()}
- ${process.env.USERNAME}
-
-
-
-
- InteractiveToken
- HighestAvailable
-
-
-
- Parallel
- false
- false
- false
- false
- false
-
- false
- false
-
- true
- true
- false
- false
- false
- PT72H
- 7
-
-
-
- "${path.join(taskDir(), `mihomo-party-run.exe`)}"
- "${exePath()}"
-
-
-
-`
-
export function createElevateTask(): void {
- const taskFilePath = path.join(taskDir(), `mihomo-party-run.xml`)
- writeFileSync(taskFilePath, Buffer.from(`\ufeff${elevateTaskXml}`, 'utf-16le'))
copyFileSync(
path.join(resourcesFilesDir(), 'mihomo-party-run.exe'),
path.join(taskDir(), 'mihomo-party-run.exe')
)
execSync(
- `C:\\\\Windows\\System32\\schtasks.exe /create /tn "mihomo-party-run" /xml "${taskFilePath}" /f`
+ `C:\\\\Windows\\System32\\schtasks.exe /create /tn "mihomo-party-run" /tr "\\"${path.join(taskDir(), `mihomo-party-run.exe`)}\\" \\"${exePath()}\\"" /sc once /st 00:00 /rl HIGHEST /f`
)
}