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 comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.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
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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 comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...