From f15f690b1944f1639b0ebdb71c6915389a5d4cda Mon Sep 17 00:00:00 2001 From: Colin Date: Wed, 26 Jun 2024 10:12:24 -0400 Subject: [PATCH] Documentation --- README.md | 4 +++- install.ps1 | 19 +++++++++++++++++++ install.sh | 0 main.go | 31 +++++++++++++++++-------------- 4 files changed, 39 insertions(+), 15 deletions(-) create mode 100644 install.ps1 delete mode 100644 install.sh diff --git a/README.md b/README.md index cd80420..2c4ad33 100644 --- a/README.md +++ b/README.md @@ -7,9 +7,11 @@ AE-Send is a Windows application that integrates into the context menu, allowing To install AE-Send, run the following command in PowerShell as Administrator: ```powershell -Invoke-WebRequest -Uri "https://git.nixc.us/colin/ae-send/raw/branch/master/dist/ae-send_windows_amd64.exe" -OutFile "$env:TEMP\ae-send.exe"; Start-Process "$env:TEMP\ae-send.exe" -ArgumentList "install" -Wait; Remove-Item "$env:TEMP\ae-send.exe" -Force +Invoke-WebRequest "https://git.nixc.us/colin/ae-send/raw/branch/master/install.ps1" -OutFile "$env:TEMP\install.ps1"; & "$env:TEMP\install.ps1"; Remove-Item "$env:TEMP\install.ps1" ``` +This command downloads and executes the installation script which sets up AE-Send on your system. + ## Usage Right-click any file in Windows Explorer to see the "Send with AE Send" option. diff --git a/install.ps1 b/install.ps1 new file mode 100644 index 0000000..8f08de8 --- /dev/null +++ b/install.ps1 @@ -0,0 +1,19 @@ +# install.ps1 + +# Download the executable to the Temp directory +$exeUrl = "https://git.nixc.us/colin/ae-send/raw/branch/master/dist/ae-send_windows_amd64.exe" +$downloadPath = "$env:TEMP\ae-send.exe" +Invoke-WebRequest -Uri $exeUrl -OutFile $downloadPath + +# Create the directory in Program Files +$installPath = "C:\Program Files\AE-Send\ae-send.exe" +New-Item -ItemType Directory -Force -Path "C:\Program Files\AE-Send" + +# Copy the executable to the Program Files directory +Copy-Item -Path $downloadPath -Destination $installPath -Force + +# Attempt to install (add context menu entry) +Start-Process -FilePath $installPath -ArgumentList "install" -Wait -Verb RunAs + +# Clean up downloaded file +Remove-Item $downloadPath -Force diff --git a/install.sh b/install.sh deleted file mode 100644 index e69de29..0000000 diff --git a/main.go b/main.go index 226c0c8..c83e669 100644 --- a/main.go +++ b/main.go @@ -28,34 +28,37 @@ func processFile(filePath string) { } func installContextMenuItem() { + exePath, _ := os.Executable() keyPath := `Software\Classes\*\shell\AE Send` - commandPath := `Software\Classes\*\shell\AE Send\command` + command := "\"" + exePath + "\" \"%1\"" - k, _, err := registry.CreateKey(registry.CURRENT_USER, keyPath, registry.SET_VALUE) + k, err := registry.OpenKey(registry.CURRENT_USER, keyPath, registry.ALL_ACCESS) if err != nil { - log.Fatalf("Unable to create registry key: %v", err) + k, _, err = registry.CreateKey(registry.CURRENT_USER, keyPath, registry.ALL_ACCESS) + if err != nil { + log.Fatalf("Failed to create registry key: %v", err) + return + } } defer k.Close() err = k.SetStringValue("", "Send with AE Send") if err != nil { - log.Fatalf("Unable to set registry value: %v", err) + log.Fatalf("Failed to set registry value: %v", err) + return } - exePath, err := os.Executable() + commandKeyPath := keyPath + `\command` + commandKey, _, err := registry.CreateKey(registry.CURRENT_USER, commandKeyPath, registry.ALL_ACCESS) if err != nil { - log.Fatalf("Unable to get executable path: %v", err) + log.Fatalf("Failed to create command key: %v", err) + return } + defer commandKey.Close() - k, _, err = registry.CreateKey(registry.CURRENT_USER, commandPath, registry.SET_VALUE) + err = commandKey.SetStringValue("", command) if err != nil { - log.Fatalf("Unable to create command registry key: %v", err) - } - defer k.Close() - - err = k.SetStringValue("", "\""+exePath+"\" \"%1\"") - if err != nil { - log.Fatalf("Unable to set command: %v", err) + log.Fatalf("Failed to set command: %v", err) } log.Println("Context menu item installed successfully.")