I will state up-front that I know fairly little about encryption and could be asking a silly question, or asking a good question in a silly way. Thank you in advance for your patience.

I have a folder, within which are Python modules as well as pickled files containing support vector machines and numpy arrays. Outside the folder I have a batch file that initiates the main module within the folder, and that main module utilizes the other modules and periodically loads the SVMs and arrays. The entire process has a duration of perhaps two hours.

I want to encrypt or otherwise secure both the folder and the batch file, such that:

  1. a user can run the batch file but cannot open or otherwise edit it;
  2. the batch file can access the folder's contents (presumably using a password hidden to the user thanks to (1);
  3. IMPORTANTLY, a user cannot access the folder's contents even when the batch file is accessing the folder; and
  4. all of this must be accomplished without the user having to explicitly install and rely on third-party software on her own system, even if the folder and batch files are moved to her system.

Is this a trivial task, or a complicated one, or impossible? Are there other approaches that would better meet (or at least come close to meeting) my four above-stated goals?

  • Sounds like a file access problem, not an encryption one. On Linux you could configure the permissions to achieve something like this; windows should have something similar.
    – Awn
    Commented Nov 28, 2016 at 8:25
  • Is this software designed just to run on this machine, or will it be distributed to other machines? If the software is made to run on other machines then there isn't much you can do about making files inaccessible or unreadable as you don't have control of the file permissions on a foreign system. Commented Nov 28, 2016 at 8:57
  • @jda, is this a Windows batch file or a Linux bash file? If you have a less-paranoid threat model and you need to use a shell script, consider a "compiler" like shc. I believe you can get away with removing the read permission and follow the rest of Serge's answer below.
    – Jedi
    Commented Dec 1, 2016 at 2:15
  • It's designed to be distributed to Windows machines. I think the best quick-and-dirty solution I've been able to find has been code obfuscation as a temporary hurdle. I do like the idea of implementing a service, although that's going to be more work than I'd hoped for.
    – jda
    Commented Dec 1, 2016 at 18:08

1 Answer 1


AFAIK, you cannot with a batch file on any Unix-like system, because when you launch a batch file, you execute the shell program (/bin/sh for example) that reads the file. AFAIK, it will be the same on Window: a batch without the read permission will not be executable by the user.

If it becomes an executable file on Unix, you can make use of the set user id mode. It a a disputable feature that allows a process to gain the authorizations of the owner of the program, instead of the ones of the user starting it, during the time of execution. That was heavily used for local games in the 70's: only the game program could read/set the scores. Here that means that the directory will be accessible to only one user (the owner of the program) and the other users will only be able to start the program.

Although very powerful, this mode has corner cases and several security implications and is now seldom used (if any) is serious application. Anyway, nothing like that exists under Windows.

The now recommended way is to have a daemon (Unix) or service (Windows) started at boot time and running under the user id of the owner of the folder, the folder being accessible only to that user. And you have front programs that communicate with the daemon/service through an interprocess communication tools such as named pipes, message queues, sockets etc.

That is slightly more complex as it involves two processes and one communication channel, but is far more secure since it cleanly separates the user interface from the processing program. But you also gain the possibility to have the user interface on remote machines and the folder with data on one single secured machine, by simply switching to a network communication channel...

  • For some reason I'm unable to mark this as the accepted answer (perhaps because the question was moved to a new SE?). I certainly would mark this as accepted if I had the ability to do so. Thank you, Serge; it's a helpful and comprehensive response.
    – jda
    Commented Dec 1, 2016 at 18:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .