LATEST UPDATES
ShareHolder Finder v0.9.3 is now released!!! Check Product Page for more details.
✉ info@automationdevelopers.com

ITS ALL ABOUT AUTOMATION

Friday, 15 April 2016

AutoIt - Unhide a file or folder


Author Post Date Friday, 15 April 2016
We can set the attributes of a file or folder using FileSetAttrib ("Path of the file(s)/ folder(s)", "+-RASHNOT" [, recurse = 0]) function.

To unhide a file or folder, we need to use "-H".

Path of the file(s)/ folder(s) - The path of the file(s) to set, e.g:- C:\*.txt, C:\AutomationDevelopers. (wildcards * and ? accepted).
+-RASHNOT - Attribute(s) to set/clear. + is used to set and - is used to clear. e.g:- "+R", "+AH-R".
The attributes that can be modified with the function are +/-:
    "R" = READONLY
    "A" = ARCHIVE
    "S" = SYSTEM
    "H" = HIDDEN
    "N" = NORMAL
    "O" = OFFLINE
    "T" = TEMPORARY
recurse [optional] - $FT_NONRECURSIVE (0) - no recursion (Default)
                                 $FT_RECURSIVE (1) - folders are recursed into.
                                 Constants are defined in FileConstants.au3. 

It returns 1 for success and 0 for failure.

In the below example, we will use the same file created with the example program in AutoIt - Write data to a file.

Example:

#include <MsgBoxConstants.au3>

;Assign the file path to a variable.
Local $sFilePath = "C:\AutomationDevelopers\temp.txt"

;Unhide C:\AutomationDevelopers\temp.txt,
Local $bStatus = FileSetAttrib($sFilePath, "-H")

If $bStatus Then
    ;If the returned value is 1, display success.
    MsgBox($MB_SYSTEMMODAL, "SUCCESS", "File attribute set to Unhide.")
Else
    ;If the returned value is 0, display error.
    MsgBox($MB_ICONERROR, "Error", "Problem setting attribute.")
EndIf

Related Posts




Interesting? Share and Let Others Know.

Post a Comment