# Is there a way to set a default application to open all file types for a specific folder?

I have a specific folder with different file types (txt, pdf, docx, anything) which when doubled-clicked on File Explorer, I do not want the default applications to open these files. Instead, I want a specific application to open these files that only reside in this specific folder.

I explain this in another way. Say folder C:\Test contains the following files:

• test.txt
• manual.pdf
• plans.docx
• finance.xlsx
• foo.mp4

If these files were found in any other folder instead of C:\Test, their default applications open them:

• plans.docx -> Microsoft Word
• finance.xlsx -> Microsoft Excel
• foo.mp4 -> Windows Media Player

But since these files are in C:\Test, when I double-click on them on File Explorer, I want them to all be opened by default_app.exe:

• test.txt -> default_app.exe
• manual.pdf -> default_app.exe
• plans.docx -> default_app.exe
• finance.xlsx -> default_app.exe
• foo.mp4 -> default_app.exe

Sorry if my Google skills aren't good enough but I have been searching for answers over some days.

• Seems it's a global setting. At least you might create in that folder a shortcut e.g. mspaint.exe, and then just drag and drop your files in. – Tech-IO Apr 3 '18 at 15:42

Short answer is no, and you wouldn't want it to work any other way.

If this could happen, then a single program could hijack entire folders in your machine. File permissions would be mismanaged, and the file system would be a fantastic target for malware.

Also, the likelihood that your one app could read all file types and make sense of them to the user is unlikely.

You can store the files in a database, and then have your program call them out of the database instead of the Windows file system. Alternatively, you can have your app make a pass across the folder and change the file extensions to ones that it alone understands, and set those associations in Windows.

You could do this with an AutoHotkey script.

; This script will intercept double-clicks and if you have double-clicked a file within a pre-defined directory,
; instead of opening the file with the default app, open the file with a custom app instead.

#Persistent
#SingleInstance, Force
#InstallKeybdHook
#HotkeyInterval, 100
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
SetTitleMatchMode 2
SetWinDelay, 0

WaitTime := DllCall("GetDoubleClickTime")
SpecialDir := "C:\Test"
ExecWith := "C:\path\to\default_app.exe"

LButton Up::
IfWinActive ahk_exe explorer.exe
{
PrevClip := ClipBoard
If (A_TimeSincePriorHotkey<400) and (A_TimeSincePriorHotkey<>-1)
{
SendInput, ^c ; Get path to file you double-clicked on
Sleep, 50 ; Sleep to give time for clipboard to get contents
If FileExist(ClipBoard)
{
Run %ExecWith% %ClipBoard%
} else {
SendInput, {LButton}
}
ClipBoard := PrevClip
} Else {
SendInput, {LButton}
}
} Else {
SendInput, {LButton}
}
Return


Just save this code to a file called explorer-double-click.ahk (or something similar ending in .ahk).

You'll want to edit the SpecialDir and ExecWith (lines 15 & 16) to set the paths appropriately.

You will need to have AutoHotkey installed first. Then run it.

• Thanks. I should have mentioned that I wouldn't want to run any 3rd party applications or scripts. – Sydrik Apr 4 '18 at 15:07
• Well, there's no way built in Windows directly to do this so the only way would be to run a third-party script. – Dean Householder Apr 5 '18 at 17:10