Jump to content

preventing a file from being deleting


Recommended Posts

Hi,

I'm managing a team network and some people changes some files I don't want they touch for security reasons (mainly config files for some softwares).

I have some exe that runs on all machines for other tasks, so I can ad some check, but I would like to simply and robustly block the file from being deleted.

Sometimes you can't delete a file because it is opened by a software. While annoying, I've tried to fileopen the file but we can still delete it. Of course the file must be readable by the user and its running softwares.

If anyone have any idea, he's wellcome ;-)

Win7 pro x64. scripts compiled to x64. - Autoit v3.3.6.1 | Scite 1.79

Link to post
Share on other sites

If the files is on a network share you can set the NTFS permissions so the file can not be deleted.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2021-06-05 - Version 1.5.4.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2021-06-14 - Version 1.6.5.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Link to post
Share on other sites

#include 'Permissions.au3'

_InitiatePermissionResources()
Dim $aPerm[2][3] = [['Administrators', 1, $FILE_AUTH_USERS_DEFAULT], ['Everyone', 1, BitOR ( $GENERIC_READ, $GENERIC_WRITE ) ]]
$ret = _SetObjectPermissions ( 'c:test.txt', $aPerm )
MsgBox(0,'','Give only read and write access to Everyone and Default access to Administrators' & @CRLF & @CRLF & '_SetObjectPermissions return value : ' & $ret )
_ClosePermissionResources()

Only Admin can delete file, and it can be read and write by everyone. :oops:

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...