1

I would like to include commands in my batch file that automatically sets the default apps for .html, .https and for Photos. I know how to change the file association by running:

ftype htmlfile="C:\Program Files\Google\Chrome\Application\chrome.exe" %1

But now I need to actually set Chrome as the default file for .https and .http. I am having a lot of trouble getting this to work, I have attempted to edit registry with no luck and have resorted to a messy but working code, that looks like this:

control /name Microsoft.DefaultPrograms /page pageDefaultProgram
SET TempVBSFile=%tmp%\~tmpSendKeysTemp.vbs
IF EXIST "%TempVBSFile%" DEL /F /Q "%TempVBSFile%"
ECHO Set WshShell = WScript.CreateObject("WScript.Shell") >>"%TempVBSFile%"
ECHO Wscript.Sleep 2000                                   >>"%TempVBSFile%"
ECHO WshShell.SendKeys "{TAB 3}"                          >>"%TempVBSFile%"
ECHO Wscript.Sleep 1000                                   >>"%TempVBSFile%"
ECHO WshShell.SendKeys "{ENTER}"                          >>"%TempVBSFile%"
ECHO Wscript.Sleep 4000                                   >>"%TempVBSFile%"
ECHO WshShell.SendKeys "{TAB 3}"                          >>"%TempVBSFile%"
ECHO Wscript.Sleep 1000                                   >>"%TempVBSFile%"
ECHO WshShell.SendKeys "{ENTER}"                          >>"%TempVBSFile%"
ECHO Wscript.Sleep 4000                                   >>"%TempVBSFile%"
ECHO WshShell.SendKeys "{TAB 2}"                          >>"%TempVBSFile%"
ECHO Wscript.Sleep 1000                                   >>"%TempVBSFile%"
ECHO WshShell.SendKeys "{ENTER}"                          >>"%TempVBSFile%"
ECHO Wscript.Sleep 4000                                   >>"%TempVBSFile%"
ECHO WshShell.SendKeys "{TAB 1}"                          >>"%TempVBSFile%"
ECHO Wscript.Sleep 1000                                   >>"%TempVBSFile%"
ECHO WshShell.SendKeys "{ENTER}"                          >>"%TempVBSFile%"
::THERE IS MORE TRUST ME BUT I DONT WANT THIS TO FILL UP THE ENTIRE POST::
CSCRIPT //nologo "%TempVBSFile%"
echo Return here once you are done.
echo.
echo ^< Press ANY key to return to the Menu ^> & Pause > NUL)
CLS & Goto :Menu

Any help would be amazing, this community has been great so far, love reading posts and get responses on my previous question. Thanks in advance for anyone who comments.

2
  • 1
    Though I don't have an answer, thanks for showing your good efforts using scripting and SendKeys()! It's relatively easy to add an application to the Open With context menu, but, since MS has started encrypting the user choice default application, setting the specific default app has become onerous. It is possible to export the key HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.html and re-import onto the same machine to set the default browser, but the key Hash might not work on another PC. Commented Nov 10, 2022 at 23:27
  • this is the proper way to do what you are asking. Commented Nov 11, 2022 at 2:00

0

You must log in to answer this question.