本帖最后由 geyee 于 2020-9-2 17:55 编辑
回复 8# flashercs
搜索发现,官网也有利用组策略这样的思路来设置IE或者Microsoft Edge为默认浏览器 https://docs.microsoft.com/en-us/microsoftsearch/set-default-browser- New-Item -Path $env:temp -Type Directory -Name "Settings"
- Start-Process Dism.exe -PassThru "/Online /Export-DefaultAppAssociations:$env:temp\Settings\AppAssoc.xml"
- $xmlpath="$env:temp\Settings\AppAssoc.xml"
- $xml=new-object -typename xml
- $xml.load($xmlpath)
-
- function replace-appassoc($sourceid,$newprogid,$newappname)
- {
- $xpath='//*[@Identifier="'+$sourceid+'"]'
- foreach ($item in (Select-Xml -xml $xml -XPath $xpath))
- {
- write-host "$($item.node.ProgId) 和 $($item.node.ApplicationName)正在被替换"
- $item.node.ProgId=$newprogid
- $item.node.ApplicationName=$newappname}
- write-host "替换完毕"
-
- }
- replace-appassoc ".htm" "IE.HTTP" "Internet Explorer"
- replace-appassoc ".html" "IE.HTTP" "Internet Explorer"
- #replace-appassoc ".html" "IE.AssocFile.HTM" "Internet Explorer"
- replace-appassoc "http" "IE.HTTPS" "Internet Explorer"
- replace-appassoc "http" "IE.HTTPS" "Internet Explorer"
-
- $xmlpath2="$env:temp\Settings\AppAssoc2.xml"
- $xml.Save($xmlpath2)
- Dism.exe /Online /Import-DefaultAppAssociations:$xmlpath2
-
复制代码
|