- 积分
- 123
- 最后登录
- 2024-3-29
- 精华
- 0
- 阅读权限
- 20
- 主题
- 32
- UID
- 205832
- 帖子
- 232
- PB币
- 1962
- 威望
- 5
- 贡献
- 0
- 技术
- 1
- 活跃
- 1167
- UID
- 205832
- 帖子
- 232
- PB币
- 1962
- 贡献
- 0
- 技术
- 1
- 活跃
- 1167
|
发表于 2022-6-18 20:16:59
IP属地北京
|显示全部楼层
前言:前两天发过一个下载和制作免安装、无升级模块的Edge的教程,被有些同学认为需借助第三方软件,是简单问题复杂化。
为了消除这样的“异见”,同时确保是从官方下载(至于说自己的网络连MS服务器慢之类的就不在本贴考虑范围内了),我研究了下几个类似的开源软件或脚本,发现官方其实除了提供公开下载入口的、但不可解压提取(至少我试过很多工具,都不行)的enterprise版的msi包外,还是提供了可解压缩的exe包的下载方式。
于是我写了个powershell脚本,一共只有13行。其中3行用于自动化查询最新版本号(x64位、Stable通道),4行用于自动化下载(其实3行也能搞定,但字符串太长不美观,我多分了1行),2行用于自动解压缩(前提是机器上有7z且包含在环境变量的Path里),4行用于清理多余文件。这下足够原生、简洁、最少键鼠操作了(双击,或右键-点用powershell运行,都只耗费2次微动)。
解压缩后的“绿色”edge,在脚本所在目录的chrome-bin\[版本号]\目录下,后面怎么用就是各位看官自己的事了。
感兴趣的同学可以自己修改脚本,如改变CPU架构、发行通道、解压缩后续的自动化操作等,我就不在此赘述了。
=============代码如下,保存成.ps1文件即可==============
$uri = "https://edgeupdates.microsoft.com/api/products"
$res = Invoke-RestMethod -Method Get -Uri $uri
$ver = (($res |? Product -eq "stable").Releases |? {$_.Architecture -eq "x64" -and $_.Platform -eq "windows"}).ProductVersion
$uri = "https://msedge.api.cdp.microsoft.com/api/v1.1/internal/contents/Browser/namespaces/Default/names/"
$uri = $uri + "msedge-stable-win-x64/versions/$ver/files?action=GenerateDownloadInfo&foregroundPriority=true"
$res = Invoke-RestMethod -Method Post -Uri $uri
Invoke-RestMethod -Uri ($res |? FileId -eq "MicrosoftEdge_X64_$ver.exe").Url -OutFile "msedge.exe"
7z x msedge.exe -y
7z x msedge.7z -y
Remove-Item msedge.*
(Get-ChildItem -Attributes Directory chrome-bin\$ver) |? {$_.Name -eq "edge_feedback"} | Remove-Item -Recurse
(Get-ChildItem -Attributes Directory chrome-bin\$ver\EBWebView) |? {$_.Name -eq "x86"} | Remove-Item -Recurse
(Get-ChildItem -Attributes !Directory chrome-bin\$ver\Locales\*.pak) |? {$_.Name -NotMatch "zh-cn"} | Remove-Item
|
-
2
查看全部评分
-
|