Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

Prevent Shared Files from Being Deleted

  • Please log in to reply
1 reply to this topic
Xia Mey
  • Members
  • 105 posts
  • Last active: Oct 01 2015 01:55 PM
  • Joined: 23 Dec 2012

Dear All


I have a couple of excel files to share my co-workers. I share them in modify so they can make change, save and also can delete but I dont want them to delete my files and Microsoft seems usless for it. May I know if AHK can prevent my files from being deleted?


Appreciate for your help

  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006

Yes, but you need to keep the script running. For example,

file_to_lock := A_ScriptFullPath
locked_file := FileOpen(file_to_lock, "r-d")
MsgBox Click OK to exit and unlock the file.
; locked_file.Close() ; Optional when exiting.

Replace A_ScriptFullPath with "the path of your file".  This example locks the script itself.


To lock multiple files, you would need to call FileOpen once for each file and store the return value in a different variable (or an array) each time.


If you want it to just sit silently until you exit it from the system tray, remove MsgBox and ExitApp and add #Persistent.