Skip to content
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

Silent install switch #52

Closed
Enovale opened this issue Apr 4, 2021 · 13 comments
Closed

Silent install switch #52

Enovale opened this issue Apr 4, 2021 · 13 comments
Labels
enhancement New feature or request

Comments

@Enovale
Copy link

Enovale commented Apr 4, 2021

Is your feature request related to a problem? Please describe.
I want to create a Windows setup script that installs all my favorite programs and I want as much as it as humanly possible to be silent and installed in the background.

Describe the solution you'd like
A switch you can use when running the installer exe, in the same format as most .msi files (/S, /SILENT, /VERYSILENT, /quiet, etc) that will automatically accept the license agreement, and start the installation immediately. (Preferably without even showing the GUI using /VERYSILENT). Since you can install the program to multiple installations of discord and you cant be certain of which one the user wants to install to, you can also have a secondary switch like /stable, /canary, /ptb.

Example: BetterDiscord-Installer.exe /S /stable

Describe alternatives you've considered
I could use AutoHotKey or some kind of memory alteration but that's really difficult to do consistently, and will probably break after any updates to the software.

Additional context
Please forgive me if something like this is already possible that I missed. I tried all the aforementioned switches as well as looking at the index.js of the code and I see no references to process.argv within the entire project

@Enovale Enovale added the enhancement New feature or request label Apr 4, 2021
@Tropix126
Copy link
Member

This is a good suggestion and will be considered for a future release. A possible solution to your current situation would be to use the manual install scripts bundled in the BetterDiscordApp repos and build it from the source.
https://github.com/rauenzi/BetterDiscordApp/#manual-installation

@Enovale
Copy link
Author

Enovale commented Apr 4, 2021

I will definitely see if I can automate the process of manually installing BD in the meantime, thank you for the suggestion and for considering my request! :)

@rauenzi
Copy link
Member

rauenzi commented Apr 4, 2021

This is a large GUI installer, and is not meant for automated tasks like this. See my response here: BetterDiscord/BetterDiscord#382 (comment)

@Enovale
Copy link
Author

Enovale commented Apr 4, 2021

Being able to install BD silently only makes sense to me as doing it otherwise requires a lot of prerequisites. It requires git, nodejs, npm, all the needed npm packages, and some kind of package manager or predownloaded exes to install all of these things.

For example, here is the code for installing it manually via powershell:

$tempFolderPath = Join-Path $Env:Temp $(New-Guid); New-Item -Type Directory -Path $tempFolderPath | Out-Null
iwr -useb get.scoop.sh | iex | Out-Null
scoop install nodejs
$bdFolder = "$tempFolderPath/BetterDiscordApp"
git clone https://github.com/rauenzi/BetterDiscordApp.git $bdFolder *>$null | Out-Null
Start-Process "npm" -ArgumentList "install" -wo $bdFolder -RedirectStandardOutput "NUL" -NoNewWindow -Wait | Out-Null
Start-Process "npm" -ArgumentList "run build" -wo $bdFolder -RedirectStandardOutput "NUL" -NoNewWindow -Wait | Out-Null
Start-Process "npm" -ArgumentList "run inject" -wo $bdFolder -RedirectStandardOutput "NUL" -NoNewWindow -Wait | Out-Null
$discordPath = $(Get-Process -Name "Discord" | Select-Object -ExpandProperty Path)[0]
Stop-Process -Name Discord | Out-Null
Start-Process $discordPath -RedirectStandardOutput "NUL" | Out-Null

Thats a ton of code versus the two lines it would take to install it if there was switches I could use.

$(New-Object System.Net.WebClient).DownloadFile("https://github.com/BetterDiscord/Installer/releases/latest/download/BetterDiscord-Windows.exe", "./BD.exe")
Start-Process -Filepath "./BD.exe" -ArgumentList "/S /stable" -Wait

@ObserverOfTime
Copy link

Wouldn't 3 lines actually be enough?

  1. Download betterdiscord.asar from the main repo's releases.
  2. Find Discord's index.js. (may need more than one line)
  3. Prepend require("/path/to/betterdiscord.asar"); to it.

@Enovale
Copy link
Author

Enovale commented Apr 4, 2021

What asar are you talking about? Am I blind ._.

EDIT: yes i am blind

@Enovale
Copy link
Author

Enovale commented Apr 4, 2021

I didn't know thats what the installer was doing when it injected the file

That would be easier I suppose, though I still think a silent option should be added, if only just in case.

@ObserverOfTime
Copy link

Actually, I forgot it only uses that method on Linux.
The Windows method is a little different but should be just as doable.

@ObserverOfTime
Copy link

I wrote a basic PowerShell script for the installation:

param([string]$DiscordPath = (Join-Path $env:LOCALAPPDATA "Discord" "app-0.0.309" "resources"))
$asarUrl = "https://github.com/rauenzi/BetterDiscordApp/releases/latest/download/betterdiscord.asar"
$asarFile = Join-Path $env:APPDATA "BetterDiscord" "data" "betterdiscord.asar"
Invoke-WebRequest -Uri $asarUrl -OutFile (New-Item -Path $asarFile -Force)
New-Item -ItemType Directory -Path (Join-Path $DiscordPath "app") -Force >$null
Set-Content -Path (Join-Path $DiscordPath "app" "package.json") `
            -Value '{"name": "betterdiscord", "main": "index.js"}'
Set-Content -Path (Join-Path $DiscordPath "app" "index.js") `
            -Value "require('$($asarFile.Replace("\", "/").Replace("'", "\'"))')"

You can manually provide the -DiscordPath param to install to PTB/Canary or a version other than 0.0.309.

The script can be improved to allow the user to select between Stable/PTB/Canary and automatically find the path, as well as support repairing and uninstalling BD, but I will leave that to someone else.

@Enovale
Copy link
Author

Enovale commented Apr 22, 2021

Thanks for that pretty good script! I will probably integrate this into mine later.

I still stand by having an official switch for this, though.

@ObserverOfTime
Copy link

Why would you download a 63MB installer for something that can be done with a <1MB script?

@rauenzi
Copy link
Member

rauenzi commented May 7, 2021

I agree with Observer's view on this. If really needed the inject script from the main repo could be adapted for automated installs.

@rauenzi rauenzi closed this as completed May 7, 2021
@atagulalan
Copy link

@rauenzi We will still need to clone the main repository, whose uncompressed size is ~130Mb. It would be much better if there was a simple silent parameter in installer.

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

No branches or pull requests

5 participants