Skip to content

[Question] Further questions about installation of notepads-np #432

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
AkariiinMKII opened this issue Apr 3, 2025 · 0 comments
Open

Comments

@AkariiinMKII
Copy link
Contributor

AkariiinMKII commented Apr 3, 2025

When fixing #430 , I've noticed that the installer script uses Add-AppxProvisionedPackage to install the app, which adds an app package (.appx) that will install for each new user to a Windows image, and caused some problems:

So I'm wondering if it's better to use Add-AppxPackage to install for current user without a permission request

{
    "installer": {
        "script": [
            "$ProgressPreference = \"SilentlyContinue\"",
            "Add-AppxPackage -Path \"$dir\\Notepads.msixbundle\""
        ]
    }
}

And for persist folders, mounting with junction may helps backing up files in real time

{
    "post_install": [
        "$package_dir = Resolve-Path -Path \"$env:LOCALAPPDATA\\Packages\\*JackieLiu*Notepads*\" | Select-Object -ExpandProperty Path",
        "if (-not (Test-Path -Path \"$persist_dir\\LocalAppData\")) {",
        "    New-Item -Path \"$persist_dir\\LocalAppData\" -ItemType Directory -Force | Out-Null",
        "    Get-ChildItem \"$package_dir\" | Copy-Item -Destination \"$persist_dir\\LocalAppData\" -Force -Recurse",
        "}",
        "Remove-Item \"$package_dir\" -Force -Recurse",
        "New-Item -ItemType Junction -Path \"$package_dir\" -Target \"$persist_dir\\LocalAppData\" -Force | Out-Null"
    ]
}

It's also recommended to ask for confirmation before Stop-Process

{
    "uninstaller": {
        "script": [
            "$ProgressPreference = \"SilentlyContinue\"",
            "$is_running = $null -ne $(Get-Process -Name Notepads -ErrorAction SilentlyContinue)",
            "if ($is_running) {",
            "    Write-Host \"`nNotepads is running, would you like to continue?\" -ForegroundColor Yellow",
            "    $answer = Read-Host -Prompt \"Enter 'y' to continue, any other key to cancel\"",
            "    if ('y' -eq $answer) {",
            "        Write-Host \"Stopping process...\" -ForegroundColor Yellow -NoNewline",
            "        Stop-Process -Name Notepads -ErrorAction Stop",
            "        Start-Sleep -Milliseconds 250",
            "    } else {",
            "        Write-Host \"Uninstallation cancelled.\" -ForegroundColor Red",
            "        break",
            "    }",
            "}",
            "Get-AppxPackage -Name '*JackieLiu*Notepads*' | Remove-AppxPackage -PreserveRoamableApplicationData -ErrorAction Stop",
            "Resolve-Path -Path \"$env:LOCALAPPDATA\\Packages\\*JackieLiu*Notepads*\" | Remove-Item -Force -Recurse -ErrorAction SilentlyContinue"
        ]
    }
}

I have tested the modified manifest, it works well and never stuck in post_install script, even without the patch in #431 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant