Skip to content

Commit

Permalink
better uninstall
Browse files Browse the repository at this point in the history
  • Loading branch information
mienaiyami committed Oct 27, 2021
1 parent 639b4d5 commit 9cf697e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 7 deletions.
42 changes: 36 additions & 6 deletions electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import {
} from "electron";
import path from "path";
import fs from "fs";
import { homedir } from "os";
import { homedir, tmpdir } from "os";
import * as remote from "@electron/remote/main";
remote.initialize();
declare const HOME_WEBPACK_ENTRY: string;
import { spawnSync } from "child_process";
import { spawn, spawnSync } from "child_process";
if (require("electron-squirrel-startup")) app.quit();
const handleSquirrelEvent = () => {
if (process.argv.length === 1) {
Expand Down Expand Up @@ -54,10 +54,40 @@ const handleSquirrelEvent = () => {
break;

case "--squirrel-uninstall":
fs.unlinkSync(
path.resolve(homedir(), "AppData/Roaming/Microsoft/Windows/Start Menu/Programs/Manga Reader.lnk")
);
fs.unlinkSync(path.resolve(homedir(), "Desktop/Manga Reader.lnk"));
if (
fs.existsSync(
path.resolve(
homedir(),
"AppData/Roaming/Microsoft/Windows/Start Menu/Programs/Manga Reader.lnk"
)
)
)
fs.unlinkSync(
path.resolve(
homedir(),
"AppData/Roaming/Microsoft/Windows/Start Menu/Programs/Manga Reader.lnk"
)
);
if (fs.existsSync(path.resolve(homedir(), "Desktop/Manga Reader.lnk")))
fs.unlinkSync(path.resolve(homedir(), "Desktop/Manga Reader.lnk"));
const uninstallFull = `
set WshShell = CreateObject("Wscript.shell")
WScript.Sleep 30000
Dim FSO
set FSO=CreateObject("Scripting.FileSystemObject")
FSO.DeleteFolder("${app.getPath("userData")}")
FSO.DeleteFolder("${rootFolder}\\*")
`;
const temp = fs.mkdtempSync(path.join(tmpdir(), "foo-"));
fs.writeFileSync(path.join(temp, "uninstall.vbs"), uninstallFull);
// const cmd = spawn("cmd.exe", ["/K"], { detached: true });
// cmd.stdin.write("start " + temp + " \r\n");
spawn("cscript.exe", [path.resolve(temp, "uninstall.vbs")], {
detached: true,
});
// spawnSync("cscript.exe", [path.resolve(temp, "uninstall.vbs")]);
// fs.unlinkSync(path.resolve(rootFolder));
// fs.unlinkSync(app.getPath("userData"));
app.quit();
break;

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "mangareader",
"productName": "Manga Reader",
"version": "2.1.3",
"version": "2.1.4",
"description": "App to read manga on desktop",
"main": "./.webpack/main/index.js",
"author": {
Expand Down

0 comments on commit 9cf697e

Please sign in to comment.