Hello all,

I was trying to make a folder secure. So when the folder is opened( or any operation is performed on the folder like deletion) an application would open and ask for password. The application i have is an exe file which is dos based and asks for password. Is there any way to make this sort of connection between the file and the folder ? or should i write some batch files like autoexec.bat ?

Thanks all in advance!

Any help would be greatly appreciated.

Arbus

Dani AI

Generated

Placing an EXE that pops up for a password whenever a normal folder is opened is not a supported, secure pattern on Windows. The autorun/autorun.inf mechanism is designed for inserted media (CD/DVD and, historically, some removable drives) and has been restricted by Microsoft because of malware abuses — simply dropping an .inf into a folder will not reliably run your program and is actively discouraged. Microsoft Autorun documentation and the related Microsoft security advisory explain why this is unreliable and was locked down. (learn.microsoft.com)

If the requirement is to intercept folder operations (open, delete, create), that is a developer-level job: either a Shell namespace/extension so Explorer delegates the folder view to your code, or a kernel-mode file-system filter (minifilter) that watches Create/Open/Delete I/O. Both are nontrivial, require signed drivers or in-process COM DLLs, and carry stability/security risks — not something a batch file or autorun can provide. See Microsoft guidance on namespace extensions and file-system filter drivers. (learn.microsoft.com)

Practical, secure alternative (recommended):

  • Use an encrypted container/volume that requires a password to mount; mount it to work with files and dismount when finished. This gives real protection even if autorun is bypassed. See the VeraCrypt beginner tutorial for the typical workflow.
  • After moving plaintext into the encrypted volume, securely wipe the originals (for example with Sysinternals SDelete) so remnants cannot be recovered.
  • NTFS permissions can help in multi-user environments, but administrators can take ownership or reset ACLs, so permissions alone are not a robust secret-protection method. (veracrypt.io)

Summary for this thread: ’s autorun idea is understandable but unreliable; and were correct that Windows does not offer a simple folder-open hook for security; ’s direction toward encryption is the practical route. For a true hook that runs on every open/delete you must write and maintain a shell extension or minifilter (high complexity) — for most users an encrypted container + secure-delete is faster, safer, and supported. (learn.microsoft.com)

Recommended Answers

All 12 Replies

Windows doesn't natively support this. If you want to password protect something on the file system, unforunately you will have to encrypt it. There's some software out there already that do this exact function.

There may be a way to do this with a programming language such as C++, but it is definately beyond writing anything in batch. You would need to either modify windows system files, or attach to explorer.exe and halt the accessing/tampering of certain things in the file system.

Make an exe file that contains a code which can ask user for password and handle it accordingly. Make a new file with extension ".inf" in which you will include the below lines:
[autorun]
open=filename.exe /argument1

Now whenever you will call/open your folder containing these files, the .inf file will automatically be called and thus your exe file will be executed.

However, the only problem here is most probably your antivirus can remove this .inf file considering it as some kind of virus.

YOu can use truecrypt or other softwares to password encrypt your files or folders.

Thaks for your replies:)
:
Where do i put the inf file ?
:
Yes jingda, But i want to try this way and moreover the softwares i downloaded are all trialwares.

How can i halt access to certain folders ? Is it related to putting some restrictions on certain directories.

Put that inf file inside the folder that you are talking about.

:
I did that but when i opened the folder no exe file executed

Then try to edit the file and insert an additional line in it.

[version] 
$WINDOWS NT$

Note: Windows will start the file while opening the folder and not instead, so your files won't be protected. On top of this, anybody can open that folder with a 3rd party program or with disabled autorun, so it's not real security.

Have to agree with you MoZ01, but is always better than nothing.

You can always use 7zip (free) or anything else to encrypt stuff instead.

TrueCrypt which is suggested earlier, is also free. - NO trial ware, and NO nag screens and such, but fully functional.

Using truecrypt, you can create a highly encrypted file, and mount it as a drive with a folder structure.

Another option could be to create a new small partition on your harddrive, and encrypt it with bitlocker. But that is even more trouble than using truecrypt imo., and still isn't what you ask for (which isn't functionally sane btw. ;) ), so I recommend TC as the best safe alternative as I see it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.