Search code examples
batch-filepasswordslocking

Keep batch file from being edited


Can I lock or set a password to a batch file/script, I have made a script but I don't want people on my work to change it. They must be able to run it but not edit it.

Is this possible and how?

I have search for it but I can't find it. I find all about how to lock PC or something else but not my batch file/script and the Q is not how to hide my script or something but if you whant to edit it, it gives a error or if you click on edit it don't work.


Solution

  • If you don't want them to be able to commit changes to the file, just set the file permissions, only allowing you (or some admin group) to modify the file.

    This command will remove inherited ACL entries, grant you full permission, and grant everyone else read permission:

    icacls your_file.cmd /inheritance:r /grant youruserid:F /grant everyone:RX