@@ -9,6 +9,7 @@ import { readRegistryKey } from "./windows.ts";
99import { which } from "./path.ts" ;
1010import { error , info } from "log/mod.ts" ;
1111import { fetcher } from "../command/tools/tools/chromium.ts" ;
12+ import { existsSync } from "https://deno.land/[email protected] /fs/mod.ts" ; 1213
1314// deno-lint-ignore no-explicit-any
1415let puppeteerImport : any = undefined ;
@@ -209,17 +210,28 @@ async function findChrome(): Promise<string | undefined> {
209210 }
210211 } else if ( Deno . build . os === "windows" ) {
211212 // Try the HKLM key
212- path = await readRegistryKey (
213- "HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\chrome.exe" ,
214- "(Default)" ,
215- ) ;
216-
217- // Try the HKCR key
218- if ( ! path ) {
213+ const programs = [ "chrome.exe" , "msedge.exe" ] ;
214+ for ( let i = 0 ; i < programs . length ; i ++ ) {
219215 path = await readRegistryKey (
220- "HKCR\\ChromeHTML\\shell\\open\\command" ,
216+ "HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\" +
217+ programs [ i ] ,
221218 "(Default)" ,
222219 ) ;
220+ if ( path && existsSync ( path ) ) break ;
221+ }
222+
223+ // Try the HKCR key
224+ if ( ! path ) {
225+ const regKeys = [ "ChromeHTML" , "MSEdgeHTM" ] ;
226+ for ( let i = 0 ; i < regKeys . length ; i ++ ) {
227+ path = await readRegistryKey (
228+ `HKCR\\${ regKeys [ i ] } \\shell\\open\\command` ,
229+ "(Default)" ,
230+ ) ;
231+ path = path ?. match ( / " ( .* ) " / ) ;
232+ path = path ? path [ 1 ] : undefined ;
233+ if ( path && existsSync ( path ) ) break ;
234+ }
223235 }
224236 }
225237 return path ;
0 commit comments