-
-
Save SonOfDiablo/81f3d610295c69c777b512e4da90393d to your computer and use it in GitHub Desktop.
$ProgressPreference='SilentlyContinue' | |
Write-Host "Finding OS Architecture: " -ForegroundColor DarkCyan -NoNewline | |
# Find Os Architecture | |
if((Get-ComputerInfo).OsArchitecture -eq "64-bit"){ | |
$arch = "*win64*" | |
Write-Host "64-bit" -ForegroundColor Green | |
}else{ | |
$arch = "*win32*" | |
Write-Host "32-bit" -ForegroundColor Green | |
} | |
Write-Host "Making Temp Directory: " -ForegroundColor DarkCyan -NoNewline | |
# Generate random 10 char string | |
$tmp = -join (((48..57) + (65..90) + (97..122)) * 120 | Get-Random -Count 10 | ForEach-Object {[char]$_}) | |
# Make temp directory | |
$tmpDir = "$env:TEMP\tmp.$tmp" | |
mkdir $tmpDir *>$null | |
Write-Host "$tmpDir" -ForegroundColor Green | |
Write-Host "Downloading zip: " -ForegroundColor DarkCyan -NoNewline | |
# Download zip | |
$tmpLocation = "$tmpDir\geckodriver.zip" | |
$downloadUrl = (((Invoke-WebRequest -Uri "https://api.github.com/repos/mozilla/geckodriver/releases/latest" -UseBasicParsing).content | ConvertFrom-Json).assets | Where-Object name -Like $arch).browser_download_url | |
Invoke-WebRequest -Uri $downloadUrl -OutFile $tmpLocation -UseBasicParsing | |
Write-Host "Done!" -ForegroundColor Green | |
Write-Host "Extracting exe: " -ForegroundColor DarkCyan -NoNewline | |
# Unzip | |
Expand-Archive -LiteralPath $tmpLocation -DestinationPath $tmpDir | |
Write-Host "Done!" -ForegroundColor Green | |
Write-Host "Checking if gecodriver already exists: " -ForegroundColor DarkCyan -NoNewline | |
$installDir = "$env:APPDATA\geckodriver" | |
$shouldCopy = $true | |
if(Test-Path "$installDir\geckodriver.exe"){ | |
Write-Host "gecodriver already exists" -ForegroundColor DarkYellow | |
Write-Host "Checking file hashes: " -ForegroundColor DarkCyan -NoNewline | |
if((Get-FileHash "$installDir\geckodriver.exe").hash -eq (Get-FileHash "$tmpDir\geckodriver.exe").hash){ | |
Write-Host "Hashes match!" -ForegroundColor DarkYellow | |
$shouldCopy = $false | |
}else{ | |
Write-Host "Hashes doesn't match" -ForegroundColor Green | |
Write-Host "Removing old exe: " -ForegroundColor DarkCyan -NoNewline | |
Remove-Item -LiteralPath "$installDir\geckodriver.exe" -Force | |
Write-Host "Done!" -ForegroundColor Green | |
} | |
}else{ | |
Write-Host "gecodriver doesn't exist" -ForegroundColor Green | |
Write-Host "Creating install directory in AppData: " -ForegroundColor DarkCyan -NoNewline | |
if(!(Test-Path $installDir)){ | |
mkdir $installDir *>$null | |
} | |
Write-Host "Done!" -ForegroundColor Green | |
} | |
if($shouldCopy){ | |
# Copy exe from temp directory to install directory | |
Write-Host "Copying exe: " -ForegroundColor DarkCyan -NoNewline | |
Copy-Item -LiteralPath "$tmpDir\geckodriver.exe" -Destination "$installDir\geckodriver.exe" | |
Write-Host "Done!" -ForegroundColor Green | |
} | |
Write-Host "Cleaning Up: " -ForegroundColor DarkCyan -NoNewline | |
# Clean Up | |
Remove-Item -LiteralPath $tmpDir -Force -Recurse | |
Write-Host "Done!" -ForegroundColor Green | |
Write-Host "Adding gecodriver to Path: " -ForegroundColor DarkCyan -NoNewline | |
# Adding gecodriver to Path | |
$userPath = [System.Environment]::GetEnvironmentVariable("Path", "User") | |
if($userPath -like "*;$installDir*"){ | |
Write-Host "gecodriver already in Path" -ForegroundColor DarkYellow | |
}else{ | |
[System.Environment]::SetEnvironmentVariable("Path", "$userPath;$installDir", "User") | |
Write-Host "Done!" -ForegroundColor Green | |
Write-Host "Updating session Path: " -ForegroundColor DarkCyan -NoNewline | |
# Update session Path | |
$env:Path = "$env:Path;$installDir" | |
Write-Host "Done!" -ForegroundColor Green | |
} |
$ProgressPreference='SilentlyContinue' | |
if((Get-ComputerInfo).OsArchitecture -eq "64-bit"){ | |
$arch = "*win64*" | |
}else{ | |
$arch = "*win32*" | |
} | |
$tmp = -join (((48..57) + (65..90) + (97..122)) * 120 | Get-Random -Count 10 | ForEach-Object {[char]$_}) | |
$tmpDir = "$env:TEMP\tmp.$tmp" | |
mkdir $tmpDir *>$null | |
$tmpLocation = "$tmpDir\geckodriver.zip" | |
$downloadUrl = (((Invoke-WebRequest -Uri "https://api.github.com/repos/mozilla/geckodriver/releases/latest" -UseBasicParsing).content | ConvertFrom-Json).assets | Where-Object name -Like $arch).browser_download_url | |
Invoke-WebRequest -Uri $downloadUrl -OutFile $tmpLocation -UseBasicParsing | |
Expand-Archive -LiteralPath $tmpLocation -DestinationPath $tmpDir | |
$installDir = "$env:APPDATA\geckodriver" | |
$shouldCopy = $true | |
if(Test-Path "$installDir\geckodriver.exe"){ | |
if((Get-FileHash "$installDir\geckodriver.exe").hash -eq (Get-FileHash "$tmpDir\geckodriver.exe").hash){ | |
$shouldCopy = $false | |
}else{ | |
Remove-Item -LiteralPath "$installDir\geckodriver.exe" -Force | |
} | |
}else{ | |
if(!(Test-Path $installDir)){ | |
mkdir $installDir *>$null | |
} | |
} | |
if($shouldCopy){ | |
Copy-Item -LiteralPath "$tmpDir\geckodriver.exe" -Destination "$installDir\geckodriver.exe" | |
} | |
Remove-Item -LiteralPath $tmpDir -Force -Recurse | |
$userPath = [System.Environment]::GetEnvironmentVariable("Path", "User") | |
if($userPath -like "*;$installDir*"){ | |
}else{ | |
[System.Environment]::SetEnvironmentVariable("Path", "$userPath;$installDir", "User") | |
$env:Path = "$env:Path;$installDir" | |
} |
@mobilegmyt the error indicates that Internet Explorer isn't installed (or at least not configured on your PC).
If you for some reason don't have IE on your PC try changing line 24 from
$downloadUrl = (((Invoke-WebRequest -Uri "https://api.github.com/repos/mozilla/geckodriver/releases/latest").content | ConvertFrom-Json).assets | Where-Object name -Like $arch).browser_download_url
to
$downloadUrl = (((Invoke-WebRequest -Uri "https://api.github.com/repos/mozilla/geckodriver/releases/latest" -UseBasicParsing).content | ConvertFrom-Json).assets | Where-Object name -Like $arch).browser_download_url
If you do have IE installed you might just not have ever ran it, in that case you should be good with just running IE once without changing the script.
Please let me know which of the two options you used and if it worked for you :)
This should mean it worked right? Gonna try testing the epic games redeemer again.
Finding OS Architecture: 64-bit
Making Temp Directory: C:\Users\Michael\AppData\Local\Temp\tmp.H5nbgXnNfb
Downloading zip: Done!
Extracting exe: Done!
Checking if gecodriver already exists: gecodriver doesn't exist
Creating install directory in AppData: Done!
Copying exe: Done!
Cleaning Up: Done!
Adding gecodriver to Path: gecodriver already in Path
PS C:\Users\Michael\Downloads\Free-Games>
Yup that looks like it works fine :)
Maybe should change the script as described in https://gist.github.com/SonOfDiablo/81f3d610295c69c777b512e4da90393d#gistcomment-3469500 cuz no one uses IE lol.
@mobilegmyt Just did that.
I didn't know this was an issue until now, I usually use IE at least once to download another browser.
PS D:\Download\Edge> .\download_geckodriver_clean.ps1
PS D:\Download\Edge> .\download_geckodriver.ps1
Finding OS Architecture: 32-bit
Making Temp Directory: C:\Users\86765\AppData\Local\Temp\tmp.RdllkE4nO5
Downloading zip: Done!
Extracting exe: Done!
Checking if gecodriver already exists: gecodriver already exists
Checking file hashes: Hashes match!
Cleaning Up: Done!
Adding gecodriver to Path: gecodriver already in Path
PS D:\Download\Edge>
is this right?
PS D:+下载+边缘>.\download_geckodriver_clean.ps1 PS D:+下载+边缘>[download_geckodriver.ps1查找操作系统架构:32 位制作温度目录:C:=用户]86765]应用数据本地\tmp。Rdllke4no5下载拉链: 完成!提取 exe: 完成!检查格子驱动器是否已经存在: 格子司机已经存在检查文件哈希: 哈希匹配!清理:完成!将格子驱动器添加到路径:已经在路径PS D 中的格子驱动者:+下载+边缘>
这是对的吗?
first download_geckodriver_clean.ps1
then download_geckodriver.ps1
@Ohihahaha the two scripts does the same thing, Clean just doesn't have comments and output to console (It's less verbose).
It does look like the scripts ran correctly however :)
Windows 7 SP1 x64
PS 5.1
PS C:\Users\PC> Set-ExecutionPolicy RemoteSigned
Execution Policy Change
The execution policy helps protect you from scripts that you do not trust. Changing the execution policy might expose
you to the security risks described in the about_Execution_Policies help topic at
http://go.microsoft.com/fwlink/?LinkID=135170. Do you want to change the execution policy?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): y
PS C:\Users\PC> C:\81f3d610295c69c777b512e4da90393d-3bf37d72a678c5d3934355937e84e9928de4ad09\81f3d610295c69c777b512e4da9
0393d-3bf37d72a678c5d3934355937e84e9928de4ad09\download_geckodriver.ps1
Finding OS Architecture: Get-ComputerInfo : Unable to find an entry point named 'GetFirmwareType' in DLL 'kernel32.dll'.
At C:\81f3d610295c69c777b512e4da90393d-3bf37d72a678c5d3934355937e84e9928de4ad09\81f3d610295c69c777b512e4da90393d-3bf37d
72a678c5d3934355937e84e9928de4ad09\download_geckodriver.ps1:5 char:5
+ if((Get-ComputerInfo).OsArchitecture -eq "64-bit"){
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-ComputerInfo], EntryPointNotFoundException
+ FullyQualifiedErrorId : System.EntryPointNotFoundException,Microsoft.PowerShell.Commands.GetComputerInfoCommand
Making Temp Directory: C:\Users\PC\AppData\Local\Temp\tmp.QZUXAK4dHR
Downloading zip: Invoke-WebRequest : The request was aborted: Could not create SSL/TLS secure channel.
At C:\81f3d610295c69c777b512e4da90393d-3bf37d72a678c5d3934355937e84e9928de4ad09\81f3d610295c69c777b512e4da90393d-3bf37d
72a678c5d3934355937e84e9928de4ad09\download_geckodriver.ps1:24 char:19
+ ... oadUrl = (((Invoke-WebRequest -Uri "https://api.github.com/repos/mozi ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebExc
eption
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
Invoke-WebRequest : Cannot validate argument on parameter 'Uri'. The argument is null or empty. Provide an argument
that is not null or empty, and then try the command again.
At C:\81f3d610295c69c777b512e4da90393d-3bf37d72a678c5d3934355937e84e9928de4ad09\81f3d610295c69c777b512e4da90393d-3bf37d
72a678c5d3934355937e84e9928de4ad09\download_geckodriver.ps1:25 char:24
+ Invoke-WebRequest -Uri $downloadUrl -OutFile $tmpLocation -UseBasicPa ...
+ ~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Invoke-WebRequest], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
Done!
Extracting exe: Expand-Archive : The path 'C:\Users\PC\AppData\Local\Temp\tmp.QZUXAK4dHR\geckodriver.zip' either does no
t exist or is
not a valid file system path.
At C:\81f3d610295c69c777b512e4da90393d-3bf37d72a678c5d3934355937e84e9928de4ad09\81f3d610295c69c777b512e4da90393d-3bf37d
72a678c5d3934355937e84e9928de4ad09\download_geckodriver.ps1:30 char:1
+ Expand-Archive -LiteralPath $tmpLocation -DestinationPath $tmpDir
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (C:\Users\PC\App...geckodriver.zip:String) [Expand-Archive], InvalidOpe
rationException
+ FullyQualifiedErrorId : ArchiveCmdletPathNotFound,Expand-Archive
Done!
Checking if gecodriver already exists: gecodriver doesn't exist
Creating install directory in AppData: Done!
Copying exe: Copy-Item : Cannot find path 'C:\Users\PC\AppData\Local\Temp\tmp.QZUXAK4dHR\geckodriver.exe' because it doe
s not exist.
At C:\81f3d610295c69c777b512e4da90393d-3bf37d72a678c5d3934355937e84e9928de4ad09\81f3d610295c69c777b512e4da90393d-3bf37d
72a678c5d3934355937e84e9928de4ad09\download_geckodriver.ps1:60 char:5
+ Copy-Item -LiteralPath "$tmpDir\geckodriver.exe" -Destination "$i ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\Users\PC\App...geckodriver.exe:String) [Copy-Item], ItemNotFoundExce
ption
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.CopyItemCommand
Done!
Cleaning Up: Done!
Adding gecodriver to Path: gecodriver already in Path
@i486 I'm sorry this is script was written and tested on Windows 10.
I'm not sure if it works on Windows 7 and I don't have what it takes to test it.
Are these errors important?
PS C:\Users\Michael\Downloads\Free-Games> .\download_geckodriver.ps1 Finding OS Architecture: 64-bit Making Temp Directory: C:\Users\Michael\AppData\Local\Temp\tmp.F0ypRGJPit Downloading zip: Invoke-WebRequest : The response content cannot be parsed because the Internet Explorer engine is not available, or Internet Explorer's first-launch configuration is not complete. Specify the UseBasicParsing parameter and try again. At C:\Users\Michael\Downloads\Free-Games\download_geckodriver.ps1:24 char:19
d
Invoke-WebRequest : Cannot validate argument on parameter 'Uri'. The argument is null or empty. Provide an argument
that is not null or empty, and then try the command again.
At C:\Users\Michael\Downloads\Free-Games\download_geckodriver.ps1:25 char:24
Done!
Extracting exe: Expand-Archive : The path 'C:\Users\Michael\AppData\Local\Temp\tmp.F0ypRGJPit\geckodriver.zip' either does not exist
or is not a valid file system path.
At C:\Users\Michael\Downloads\Free-Games\download_geckodriver.ps1:30 char:1
Done!
Checking if gecodriver already exists: gecodriver doesn't exist
Creating install directory in AppData: Done!
Copying exe: Copy-Item : Cannot find path 'C:\Users\Michael\AppData\Local\Temp\tmp.F0ypRGJPit\geckodriver.exe' because it does not
exist.
At C:\Users\Michael\Downloads\Free-Games\download_geckodriver.ps1:60 char:5
ption
Done!
Cleaning Up: Done!
Adding gecodriver to Path: gecodriver already in Path