How to prevent a file being copied or cut in windows file system?

16,674

Solution 1

If you need the exe to be executable, you need to permit loading it into memory. As soon as you do, anyone can read it to memory using ReadFile and then write to an arbitrary location using WriteFile. No shell-detectable copying involved.

A good reading: Raymond's post and its comments on preventing copying.

Solution 2

As others have suggested you won't be able to disable the copy/cut behaviour so easily.
An alternative would be to disable the execution of the copied versions.
In your executable you could check many things like :

  • The path of the present executable is explicitly your_path
  • The name of the machine and user is the one you authorise

You could even prevent the file of being executed more than once using Windows register entries (if already 1 don't launch). It won't be perfect since any experimented user could tweak that out, assuming they are seeking for that. But depending on your users profile it might be sufficient.

Share:
16,674
Admin
Author by

Admin

Updated on June 05, 2022

Comments

  • Admin
    Admin almost 2 years

    I want that an exe file can't be copied or cut from the Windows file system to paste somewhere.

    The exe is made in C#. which must have to be in only one PC.

    I have worked with FileSystemWatcher, NSIS, Clipboard. but for all I need to detect whether that file is being copied.

    I also have seen 'Prevent'(http www free-download-blog.com disable-cut-paste-copy-delete-rename-functions-using-prevent ), but I need to prevent only that particular exe from being copied or cut.

    Any pointer or idea will help.

  • James
    James about 14 years
    "Digital files cannot be made uncopyable, any more than water can be made not wet." --Bruce Schneier
  • Matteo Italia
    Matteo Italia about 14 years
    Exactly, if a user can read a file he can also copy it, period. And even if he don't have privileges to read it, any sufficiently determined attacker will be able to circumvent any protection if he has local access or administrator rights.
  • user1686
    user1686 about 14 years
    Another way: One can also execute the program inside a debugger, and dump its process memory back to a file.