Revised the installation file for Powershell for more clear readability during the installation process

This commit is contained in:
Pietro Quintavalle
2024-06-09 14:33:51 +02:00
parent 382b810669
commit 634a505cad
2 changed files with 27 additions and 8 deletions
+2
View File
@@ -0,0 +1,2 @@
/ObsidianInstaller.exe
.idea
+25 -8
View File
@@ -11,20 +11,37 @@ function Install-Obsidian-Windows {
Write-Output "Chocolatey is not installed. Installing Chocolatey..." Write-Output "Chocolatey is not installed. Installing Chocolatey..."
Set-ExecutionPolicy Bypass -Scope Process -Force; Set-ExecutionPolicy Bypass -Scope Process -Force;
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072;
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')); $script = (New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')
Invoke-Command -ScriptBlock ([ScriptBlock]::Create($script))
} }
choco install -y wget jq choco install -y jq
Write-Output "Downloading Obsidian installer..." Write-Output "Downloading Obsidian installer..."
wget https://github.com/obsidianmd/obsidian-releases/releases/download/v1.6.3/Obsidian.1.6.3.exe -OutFile ObsidianInstaller.exe Invoke-WebRequest -Uri "https://github.com/obsidianmd/obsidian-releases/releases/download/v1.6.3/Obsidian.1.6.3.exe" -OutFile "ObsidianInstaller.exe"
# Check if the installer was downloaded # Check if the installer was downloaded
if (Test-Path "ObsidianInstaller.exe") { if (Test-Path "ObsidianInstaller.exe") {
Write-Output "Running Obsidian installer..." Write-Output "Running Obsidian installer..."
Start-Process -FilePath .\ObsidianInstaller.exe -ArgumentList "/S" -NoNewWindow -Wait $startProcess = Start-Process -FilePath .\ObsidianInstaller.exe -ArgumentList "/S" -PassThru -Wait
Write-Output "Installer exit code: $($startProcess.ExitCode)"
# Check if Obsidian was installed and create a symbolic link for testing # Check for Obsidian executable in possible installation paths
if (Test-Path "C:\Program Files\Obsidian\Obsidian.exe") { $obsidianPaths = @(
"C:\Program Files\Obsidian\Obsidian.exe",
"$env:LOCALAPPDATA\Programs\Obsidian\Obsidian.exe",
"$env:LOCALAPPDATA\Obsidian\Obsidian.exe"
)
$obsidianInstalled = $false
foreach ($path in $obsidianPaths) {
if (Test-Path $path) {
$obsidianInstalled = $true
Write-Output "Obsidian found at $path"
break
}
}
if ($obsidianInstalled) {
Write-Output "Obsidian installed successfully." Write-Output "Obsidian installed successfully."
} else { } else {
Write-Output "Obsidian installation failed." Write-Output "Obsidian installation failed."
@@ -36,7 +53,7 @@ function Install-Obsidian-Windows {
} }
} }
function Install-Plugins { function Install-Plugin {
Write-Output "Installing plugins..." Write-Output "Installing plugins..."
# Kill Obsidian process if running # Kill Obsidian process if running
@@ -79,4 +96,4 @@ if (-Not (Test-Administrator)) {
# Directly run Windows installation and plugin configuration # Directly run Windows installation and plugin configuration
Install-Obsidian-Windows Install-Obsidian-Windows
Install-Plugins Install-Plugin