[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

链接丢了

不用第三方估计比较复杂,可能要考虑userchoice hash算法。需要后缀名(.html),sid,ProgId,16位十六进制时间戳(18位十进制时间戳转换而成),特定字符串这些参数。而后拼接,进行标准md5换算,继而利用微软的特定md5算法,最后base64转码得到UserChoice下ProgId对应的hash。
利用https://kolbi.cz/blog/2017/10/25 ... ociations-per-user/的工具可以方便的解决。SetDefaultBrowser.exe ie即可。
至于利用com类接口、SetAppAsDefault函数,没看太懂。以下链接可供研究。
参考:Change Default Apps, Browser or File Association via Command-line in Windows 10
win10_64 默认应用的UserChoice Hash算法学习
如何绕过Win8、Win10的systemsetting与注册表校验设置默认浏览器
How to programmatically set file associations in Windows 10
What's the Hash in HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.<extension>\UserChoice?

TOP

本帖最后由 geyee 于 2020-9-2 17:55 编辑

回复 8# flashercs

搜索发现,官网也有利用组策略这样的思路来设置IE或者Microsoft Edge为默认浏览器 https://docs.microsoft.com/en-us/microsoftsearch/set-default-browser
  1. New-Item -Path $env:temp -Type Directory -Name "Settings"
  2. Start-Process Dism.exe -PassThru "/Online /Export-DefaultAppAssociations:$env:temp\Settings\AppAssoc.xml"
  3. $xmlpath="$env:temp\Settings\AppAssoc.xml"
  4. $xml=new-object -typename xml
  5. $xml.load($xmlpath)
  6. function replace-appassoc($sourceid,$newprogid,$newappname)
  7. {
  8. $xpath='//*[@Identifier="'+$sourceid+'"]'
  9. foreach ($item in (Select-Xml -xml $xml -XPath $xpath))
  10. {
  11. write-host "$($item.node.ProgId) 和 $($item.node.ApplicationName)正在被替换"
  12. $item.node.ProgId=$newprogid
  13. $item.node.ApplicationName=$newappname}
  14. write-host "替换完毕"
  15. }
  16. replace-appassoc ".htm" "IE.HTTP" "Internet Explorer"
  17. replace-appassoc ".html" "IE.HTTP" "Internet Explorer"
  18. #replace-appassoc ".html" "IE.AssocFile.HTM" "Internet Explorer"
  19. replace-appassoc "http" "IE.HTTPS" "Internet Explorer"
  20. replace-appassoc "http" "IE.HTTPS" "Internet Explorer"
  21. $xmlpath2="$env:temp\Settings\AppAssoc2.xml"
  22. $xml.Save($xmlpath2)
  23. Dism.exe /Online /Import-DefaultAppAssociations:$xmlpath2
  24.    
复制代码

TOP

返回列表