Sign in to follow this  
Followers 0
Anaxibius

File or Folder Permissions

3 posts in this topic

Is there an easy way to edit the permissions on a particular folder or file within AutoIT? I have tried using CACLS using a Dos command RunWAit line withoput any luck. Thanks for any help.

Share this post


Link to post
Share on other sites



Is there an easy way to edit the permissions on a particular folder or file within AutoIT? I have tried using CACLS using a Dos command RunWAit line withoput any luck. Thanks for any help.

I am using the SetAcl commandline utility for that....

:lmao:


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Hey, Im a first time poster, but I often use these forums as reference. I sucessfully made a script that lets you change the permissions to a specified folder, just something basic however, Access + Deny for the current user, with a little modifcation it could be a bit more powerful, the trick is you have to pipe "Y" into the CALCS command. Here is the Code:

#include <GUIConstants.au3>
#Include <process.au3>

;Generated with Form Designer preview
$Form1 = GUICreate("Permissions", 405, 117, 190, 119)
GUICtrlCreateLabel("Folder Permissions Setter!", 16, 8, 305, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$Lock = GUICtrlCreateButton("&Lock", 40, 80, 81, 25)
$Unlock = GUICtrlCreateButton("&Unlock", 200, 80, 81, 25)
GUICtrlCreateLabel("Path:", 8, 48, 29, 17)
$path_name = GUICtrlCreateInput("", 40, 48, 241, 21, -1, $WS_EX_CLIENTEDGE)
$Browse = GUICtrlCreateButton("&Browse", 296, 48, 81, 25)
GUISetState(@SW_SHOW)
$path=""

While 1
    $msg = GuiGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $Unlock
            $path = guictrlread($path_name)
            if $path == "" Then
                MsgBox(16,"Error","No Path Name set, Please Retry.")
            ElseIf Not FileExists($path)Then
                MsgBox(16,"Error","Path name invalid!")
            Else
        ;MsgBox(0,"","ECHO Y| CACLS """& $path &""" /g  "& @UserName &":F") for debuging
                $cmd=_RunDOS("ECHO Y| CACLS """& $path &""" /g  "& @UserName &":F")
                MsgBox(0,"","UNLOCKED")
            EndIf
        Case $msg = $Browse
            $path=FileSelectFolder("Please Choose a Folder","C:\",1)
            GUICtrlSetdata($path_name,$path)
            
        Case $msg = $Lock
            $path = guictrlread($path_name)
            if $path == "" Then
                MsgBox(16,"Error","No Path Name set, Please Retry.")
            ElseIf Not FileExists($path)Then
                MsgBox(16,"Error","Path name invalid!")
            Else
        ;MsgBox(0,"","ECHO Y| CACLS """& $path &""" /d  "& @UserName ) for debuging
                $cmd=_RunDOS("ECHO Y| CACLS """& $path &""" /d  "& @UserName)
                MsgBox(0,"","Locked")
            EndIf
        Case Else
    ;;;;;;;
    EndSelect
WEnd
Exit

Permissions.zip

Permissions.au3

Edited by Demonfire

Share this post


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
Sign in to follow this  
Followers 0