File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # region Setup
2+ $AppName = " Notion"
3+ $CommonLocation = " Programs\Notion\Uninstall Notion.exe"
4+
5+ $Locations = @ (
6+ # User Locations
7+ [string ](Join-path $env: LOCALAPPDATA $CommonLocation )
8+
9+ # System Locations
10+ [string ](Join-path $env: ProgramFiles $CommonLocation )
11+ [string ](Join-path ${env: ProgramFiles(x86)} $CommonLocation )
12+ )
13+ # endregion
14+
15+ # ###########
16+
17+ # region Define Functions
18+ function Test-FilePresence {
19+ param ($f )
20+ if (Test-Path $f ){
21+ Write-Output " Located at '$f '"
22+ exit 0
23+ }
24+ }
25+ function Find-UninstallKey {
26+ param ($n )
27+ $x = @ (
28+ # User Locations
29+ " Registry::HKEY_CURRENT_USER\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall"
30+ " Registry::HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Uninstall"
31+
32+ # System Locations
33+ " Registry::HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall"
34+ " Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
35+ ) | ForEach-Object {
36+ if (Test-Path $_ ){
37+ Get-ChildItem $_ | ForEach-Object {
38+ Get-ItemProperty $_.PSPath
39+ } | Where-Object {
40+ $_.DisplayName -like " *$n *"
41+ }
42+ }
43+ }
44+ if ($null -ne $x ){
45+ Write-Output " Found Uninstall Keys"
46+ exit 0
47+ }
48+ }
49+ # endregion
50+ # region Check Presence
51+ # confirm files don't exist on common paths
52+ $Locations | ForEach-Object {
53+ Test-FilePresence -f $_
54+ }
55+
56+ # confirm no matching products installed, in case installed in a different directory
57+ Find-UninstallKey - n $AppName
58+
59+ exit 1
60+ # endregion
Original file line number Diff line number Diff line change 1+ <#
2+ . DESCRIPTION
3+ Script downloads installer for the software.
4+ Since (in most cases) we aren't allowed to redistribute the installers, a script to download them on demand is provided instead.
5+
6+ To use, fill out the parameters in the script, so all you need to do is run ./download.ps1
7+
8+ For GitHub Releases that change, a script is provided in /scripts/Get-LatestGitHubRelease.ps1 to get the latest link which you can pass in via -URI.
9+
10+ (this download script could probably be improved later down the line across the board)
11+
12+ . EXAMPLE
13+ # Get the latest ARM version of PowerShell
14+ $URI = (& '../../Scripts/Get-LatestGitHubRelease.ps1' -Repo 'PowerShell/PowerShell' -Filter {$_.name -like '*win-arm64.msi'}).DownloadURI,
15+ ./download.ps1 -URI $URI -OutFileName 'ps7-win-arm64.msi'
16+ #>
17+ [CmdletBinding ()]
18+ param (
19+ [Parameter ()]
20+ [uri ]$URI = ' https://www.notion.com/desktop/windows/download' ,
21+ [Parameter ()]
22+ [string ]$OutFileName = ' Notion-Installer.exe'
23+ )
24+
25+ $OutPath = Join-Path - Path (Join-Path $PSScriptRoot ' source' ) - ChildPath $OutFileName
26+ Invoke-RestMethod - Method Get - Uri $URI - OutFile $OutPath - UseBasicParsing - ErrorAction Stop
27+
28+ return $OutFileName
Original file line number Diff line number Diff line change 1+ Notion-Installer.exe /S
Original file line number Diff line number Diff line change 1+ :: User:
2+ cmd.exe /c " " %LOCALAPPDATA% \Programs\Notion\Uninstall Notion.exe" /S"
You can’t perform that action at this time.
0 commit comments