//path 安装路径 import win; import win.reg; import inet.downBox; import web.rest.jsonLiteClient; import process; import process.cache; import fsys.version; import fsys.latest; import inet.http; namespace chrome; class path{ ctor(enableInstaller,chromeFirst){ if(_WINE){ if(..io.exist("//opt/google/chrome/google-chrome") ){ return "//opt/google/chrome/google-chrome"; } } var path; if(chromeFirst){ path = findPath({ "chrome.exe"; "msedge.exe"; "2345Explorer.exe"; "360chrome.exe"; }) } else { path = findPath({ "msedge.exe"; "chrome.exe"; "2345Explorer.exe"; "360chrome.exe"; }) } if(!(#path && ..io.exist(path))){ for i,p in { "C:\Program Files\Supermium\chrome.exe", "C:\Program Files (x86)\Supermium\chrome.exe", ..io.appData("aardio\std\supermium\chrome.exe") } { if(..io.exist(p)){ return p; } } if(enableInstaller){ installChrome(); path = findPath({"msedge.exe";"chrome.exe"}) } } return path; }; } namespace path{ findPath = function(browsers){ var path; for i,filename in ..table.eachIndex(browsers){ var reg = ..win.reg("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\" + filename) if(reg){ path = reg.queryValue(""); reg.close(); }; if( !#path ) { var reg = ..win.reg("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\App Paths\" + filename) if(reg){ path = reg.queryValue(""); reg.close(); }; } if( #path ) { break; } } if( !#path ) { for i,filename in ..table.eachIndex(browsers){ path = ..process.cache.find(filename,,false) || ..fsys.lnk.searchInDesktop(filename); if( #path ) break; } } return path; } //legacyInstaller = null; //legacyInstallerName = null; var getChromeInstallerUrl = function(){ if(!_WIN10_LATER){ if(_WIN7_LATER){ if(_WIN_64){ return "https://dl.google.com/release2/chrome/ggsdppo5kshsyqe3fej7lv4tau_109.0.5414.165/109.0.5414.165_chrome_installer.exe" } else{ return "https://dl.google.com/release2/chrome/adj6vsv5wkrolezapn7slzvjun2a_109.0.5414.165/109.0.5414.165_chrome_installer.exe" } } if( legacyInstaller ? ..inet.http.status(legacyInstaller)==200){ return legacyInstaller,legacyInstallerName; } return "http://dl.google.com/release2/h8vnfiy7pvn3lxy9ehfsaxlrnnukgff8jnodrp0y21vrlem4x71lor5zzkliyh8fv3sryayu5uk5zi20ep7dwfnwr143dzxqijv/49.0.2623.112_chrome_installer.exe","Chrome"; } var http = ..web.rest.jsonLiteClient(); var products = http.get("http://edgeupdates.microsoft.com/api/products"); http.close(); if(products){ var architecture = _WIN_64 ? "x64" : "x86"; for i,product in ..table.eachIndex(products){ if(product[["Product"]] == "Stable"){ var releases = product[["Releases"]] for i,release in ..table.eachIndex(releases){ if((release.Platform!="Windows") || (release.Architecture != architecture)){ continue; } for i,artifact in ..table.eachIndex(release.Artifacts){ if(artifact.ArtifactName=="msi"){ return artifact.Location,"Microsoft Edge"; } } } } } } } installChrome = function(){ var url,chromeName = getChromeInstallerUrl(); if(!url){ return; } var downBox = ..inet.downBox(mainForm, "正在下载本程序运行必需组件:"+(chromeName||"Chrome"),1000) var downloadPath = _WIN10_LATER ? ..io.appData("/aardio/edge/MicrosoftEdgeEnterprise.msi") : ..io.appData("/aardio/edge/Chrome-Install.exe") downBox.endProc = function(ret,fileSize,unmodified){ if(_WIN10_LATER) return; downBox.progress.setProgressRange(1,50); downBox.progress.startProgress(); downBox.text = "正在安装本程序运行必需组件" ; downBox.labInfo.text = "正在安装:Chrome" ; downBox.labProgress.text = "可能需要数分钟, 请稍候 ... "; ..process.executeWait(downloadPath,"/silent /install"); } downBox.download(url,downloadPath); if(downBox.complete && _WIN10_LATER){ return ..process.executeWait(downloadPath ," /qn /quiet /passive /norestart") } } profile = function(p,path,uDir){ if(uDir===null) { return profile(p,path,..io.appData("\Microsoft\Edge\User Data\")) || profile(p,path,..io.appData("\Google\Chrome\User Data\")); } var profilePath; if(p===null){ profilePath = ..fsys.latest(uDir,{"Profile*","Default"}); } elseif(p) { profilePath = ..io.joinpath(uDir,p); } if( ..io.exist(profilePath) ){ if(path) profilePath = ..io.joinpath(profilePath,path); return ..io.exist(profilePath) } } } /**intellisense() chrome.path( = 用于获取 Edge(Chromium )、Chrome 、 Supermium 安装路径 chrome.path(.(允许自动安装,优先查找Chrome) = 用于获取 Chrome 安装路径,所有参数可省略。\n支持 Chrome 、 Edge(Chromium )、Supermium 等浏览器\n\n如果允许自动安装,且没有可用浏览器,,将会下载安装 Edge(Chromium) \n\n默认优先获取 Edge(Chromium)路径,如参数 @2 为 true 则优先获取 Chrome 路径\n\nWin10 以后系统自带 Edge(Chromium )一般不需要安装。\n如果允许自动安装,则 Win10 以后安装 Edge(Chromium )。\nWin7 安装 Chrome 109,XP 安装 Chrome 49 chrome.path.profile(.(profile,path,userDataDir) = 获取 Edget 或 Chrome 用户配置文件(Profile)所在目录。\n\n所有参数可选:\n@profile 指定配置目录名。\n@path 批定子路径。\n@userDataDir 指定用户数据根目录。\n如果返回的文件路径(拼接 @path 以后)不存在则返回 null 。 end intellisense**/