Jump to content

ProtectFolder


JScript
 Share

Recommended Posts

Hello,

I wrote this script to protect my personal folders, but I only tested in XP SP1, SP2 and Vista.

Help me to improve it, testing in other "OS".

Updated in 10/05/2012, v3.05

Download:

ProtectFolder_v3.05.1012.2600_10-05-2012.zip

Previous 530 downloads...

post-44525-12530532239556_thumb.jpgpost-44525-1253053234803_thumb.jpgpost-44525-12530532448485_thumb.jpg

Edited by JScript

http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!)

Somewhere Out ThereJames Ingram

somewh10.png

dropbo10.pngDownload Dropbox - Simplify your life!
Your virtual HD wherever you go, anywhere!

Link to comment
Share on other sites

Works really nicely. I like how the icon for the locked folders change.

An English translation would be nice.

Yes, do you translate it for me? Collaborate with me, I am without time... :D

Which Windows do you use?

Edited by jscript

http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!)

Somewhere Out ThereJames Ingram

somewh10.png

dropbo10.pngDownload Dropbox - Simplify your life!
Your virtual HD wherever you go, anywhere!

Link to comment
Share on other sites

I can still access the protected folder.

Probably because I am using XP Home SP3.

We will try to solve this...

but don't you get to write anything, only to read?

I'm not sure if the key: {2559a1f2-21d7-11d4-bdaf-00c04f60b9f0} it is present in all the versions of Windows...

Edited by jscript

http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!)

Somewhere Out ThereJames Ingram

somewh10.png

dropbo10.pngDownload Dropbox - Simplify your life!
Your virtual HD wherever you go, anywhere!

Link to comment
Share on other sites

Here's the script in English:

#Region EzSkinConvert
; #INDEX# =======================================================================================================================
; Title .........: ProtectFolder.au3
; AutoIt Version.: 3.3.0.0
; Language.......: Portuguese (Brazil)
; --------------------------------------------------- EzSkin_PreProcessor.au3 ----------------------------------------------------
; Version .......:  2.08.1809.2600
; Modified.......: By EzSkinConvert.au3
; Remarks .......: Code re-written by EzSkinConvert, created by JScript. Based on the: EzSkin_1-2-3, ver 1.0.2 - Feb 17, 2007
; Credits .......: Original EzSkin.au3 version (1.0.2 - Feb 17, 2007) is made by Valuater.
;                  For personal use only, All Rights Reserved. Thank you big_daddy, Joscpe and SmOke_N.
;                  http://www.autoitscript.com/forum/index.php?showtopic=41319&view=findpost&p=307380
; ===============================================================================================================================
#include "EzSkin_Lite(ProtectFolder).au3"
#EndRegion EzSkinConvert

#cs ----------------------------------------------------------------------------
    AutoIt Version: 3.2.12.0
    Author:         JScript (Joăo Carlos FROM BRAZIL)
                    dvi-suporte@hotmail.com / www.dvi-informatica.blogspot.com

    Script Function: ProtectFolder
#ce ----------------------------------------------------------------------------
#NoTrayIcon
;#RequireAdmin
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=.\Resources\Icons\Icon.ico
#AutoIt3Wrapper_Outfile=ProtectFolder.exe        ;Target exe/a3x filename.
#AutoIt3Wrapper_Outfile_Type=exe                ;a3x=small AutoIt3 file;  exe=Standalone executable (Default)
#AutoIt3Wrapper_Compression=0                   ;Compression parameter 0-4  0=Low 2=normal 4=High. Default=2
#AutoIt3Wrapper_UseUpx=n                        ;(Y/N) Compress output program. Default=Y
#AutoIt3Wrapper_UseAnsi=y                       ;(Y/N) Use Ansi versions for AutoIt3a or AUT2EXEa. Default=N
;** Target program Resource info
#AutoIt3Wrapper_Res_Comment=Protege uma pasta (diretório) contra Leitura/Gravaçăo năo autorizada.
#AutoIt3Wrapper_Res_Description=Protege uma pasta (diretório) contra Leitura/Gravaçăo năo autorizada.
#AutoIt3Wrapper_Res_Fileversion=2.06.2309.2600
#AutoIt3Wrapper_Res_SaveSource=n
;#AutoIt3Wrapper_Res_Language=1046
#AutoIt3Wrapper_Res_FileVersion_AutoIncrement=n  ;(Y/N/P) AutoIncrement FileVersion After Aut2EXE is finished. default=N
;                                                P=Prompt, Will ask at Compilation time if you want to increase the version number.
#AutoIt3Wrapper_Res_LegalCopyright=(C) JScript - 2009 (FROM BRAZIL)    ;Copyright field
; free form resource fields ... max 15
; you can use the following variables:
; %AutoItVer% which will be replaced with the version of AutoIt3
; %date% = PC date in short date format
; %longdate% = PC date in long date format
; %time% = PC timeformat
; eg: #AutoIt3Wrapper_Res_Field=AutoIt Version|%AutoItVer%
://////=__=
://////=__=-/.
://////=__=.=
://////=__=-/.= rights reserved.
://////=__=
://////=__=.=
; DigitalProductID is StringToBinary(@ScriptName)
://////=__=
;Add extra ICO files to the resources which can be used with TraySetIcon(@ScriptFullPath, 3) etc
; list of filename of the Ico files to be added, First one will have number 3, then 4 ..etc
; Filename of ICO to be added.
#AutoIt3Wrapper_Res_Icon_Add=.\Resources\Icons\Icon.ico
; Filename[,Section [,ResName]] to be added.
;#AutoIt3Wrapper_Res_File_Add=
;
; RUN BEFORE AND AFTER definitions
; The following directives can contain:
;   %in% , %out%, %icon% which will be replaced by the fullpath\filename.
;   %scriptdir% same as @ScriptDir and %scriptfile% = filename without extension.
;   %fileversion% is the information from the #AutoIt3Wrapper_Res_Fileversion directive
;   %scitedir% will be replaced by the SciTE program directory
;   %autoitdir% will be replaced by the AutoIt3 program directory
#AutoIt3Wrapper_Run_Before=         ;process to run before compilation - you can have multiple records that will be processed in sequence
;process to run After compilation - you can have multiple records that will be processed in sequence
;#AutoIt3Wrapper_Run_After=
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

#include <String.au3>
#include <StaticConstants.au3>
#include <ButtonConstants.au3>

Opt("ExpandEnvStrings", 1)
Opt("ExpandVarStrings", 0)

; Only for compiled
If Not @Compiled Then
; _EzSkinMsgBox( flag, "title", "text" [, timeout [, hwnd [, "ownButtons" [, left [, top [, filename [, resname _
;        [, restype [, allwaysActive ]]]]]] )
;        If Left or/and Top = -2 then active Random Position
    _EzSkinMsgBox(262160, "Error", "Only for compiled script!")
    Exit
EndIf

; Set variables
; ------------------------------------------------------------------------------
Local $sFolder = FileGetShortName(StringReplace($CmdLineRaw, '"', ""))
Local $sSendTo = @UserProfileDir & "\SendTo\ProtectFolder.lnk"
Local $sScriptPath = FileGetShortName(@ScriptFullPath)
Local $sTargetPath, $sAttrib

If $CmdLineRaw = "/FileCreateShortcut" Then
    FileCreateShortcut($sScriptPath, $sSendTo)
    Exit
EndIf

; Check...
If $sFolder = "" Then
    $sTargetPath = FileGetShortcut($sSendTo)
    If @error Then
        FileCreateShortcut($sScriptPath, $sSendTo)
    ElseIf $sTargetPath[0] <> $sScriptPath Then
        FileCreateShortcut($sScriptPath, $sSendTo)
    EndIf

    $sFolder = FileSelectFolder("Choose a folder to Lock or Unlock...", "", 7, @ScriptDir)
Else
    $sAttrib = FileGetAttrib($sFolder)
    If Not StringInStr($sAttrib, "D") Then
        If IsDeclared("sEZS_VERSION") Then
            _EzSkinMsgBox(262160, "Error!", "The ProtectFolder does not work on files, only folders!", -1, "", "", -1, -1, True)
        Else
            _EzSkinMsgBox(262160, "Error!", "The ProtectFolder does not work on files, only folders! ")
        EndIf
        Exit
    EndIf
EndIf
If $sFolder = "" Then Exit

_ProtectFolder($sFolder)

; #FUNCTION# ====================================================================================================================
; Name...........: _ProtectFolder
; Description ...: It protects a folder against no authorized reading/recording.
; Syntax.........: _ProtectFolder( "Path" )
; Parameters ....: Path     - Full Path of folder to block/unblock
; Return values .: Success     - Returns a friendly message and exit.
;                   Failure     - Returns a friendly message and exit.
; Author ........: jscript
; Modified.......:
; Remarks .......: Only tested in Microsoft Windows XP SP2.
; Related .......:
; Link ..........;
; Example .......; _ProtectFolder( @MyDocumentsDir )
; ===============================================================================================================================
Func _ProtectFolder($sPath)
    $sPath = FileGetLongName($sPath)
    ; Set variables
    Local $sOldCLSID = ""
    Local $sCLSID = "{2559a1f2-21d7-11d4-bdaf-00c04f60b9f0}" ; Windows security (2K, XP and above... Seven !?!?)
    Local $sDesktopINI = $sPath & "\Desktop.ini"
    Local $sPassword = "", $sCheckPass = ""
    Local $sSecurityKey = ""
    Local $iDropEffect = 0
    Local $sOldAttrib = ""
    Local $FileExisted = 0
    ; Verify if Desktop.ini exists...
    If FileExists($sDesktopINI) Then
        $sOldCLSID = IniRead($sDesktopINI, ".ShellClassInfo", "CLSID", "")
        $sSecurityKey = IniRead($sDesktopINI, "Security", "Key", "")
        $FileExisted = 1
    EndIf
    ; Make the folder a system folder...
    $sOldAttrib = FileGetAttrib($sPath)
    FileSetAttrib($sPath, "+S")

    If $sSecurityKey = "" Then
        While 1
;_EzSkinInputBox( "title", "Prompt" [, "Default" [, "password char" [, Width, Height [, Left, Top [, timeOut _
;        [, hwnd [, "ownButtons" [, allwaysActive ]]]]]]]] )
;        If Left or/and Top = -2 then active Random Position
;         Version 2.6    - Limitations in this version: Only the character "*" is used for masking.
            $sPassword = _EzSkinInputBox("Lock", "Enter password to lock the folder:" & @CRLF & @CRLF & $sPath, "", "*")
            If @error Or $sPassword = "" Then Exit
            $sCheckPass = _EzSkinInputBox("Lock", @CRLF & @CRLF & "Enter password again to confirm:", "", "*")
            If @error Or $sCheckPass = "" Then Exit
            If $sPassword <> $sCheckPass Then
                If IsDeclared("sEZS_VERSION") Then
                    If _EzSkinMsgBox(262197, "Error!", "The password you entered does not match!", -1, "", "", -1, -1, True) = 4 Then ContinueLoop
                Else
                    If _EzSkinMsgBox(262197, "Error!", "The password you entered does not match!") = 4 Then ContinueLoop
                EndIf
                Exit
            EndIf
            ExitLoop
        WEnd
        IniWrite($sDesktopINI, ".ShellClassInfo", "CLSID", $sCLSID)
        If $sOldCLSID <> "" Then IniWrite($sDesktopINI, "Security", "OldCLSID", $sOldCLSID)
        $iDropEffect = IniRead($sDesktopINI, ".ShellClassInfo", "DefaultDropEffect", 0)
        If $iDropEffect > 0 Then IniWrite($sDesktopINI, "Security", "DefaultDropEffect", $iDropEffect)
        IniWrite($sDesktopINI, ".ShellClassInfo", "DefaultDropEffect", 4)
        IniWrite($sDesktopINI, "Security", "Key", _StringToHex($sPassword))
        IniWrite($sDesktopINI, "Security", "FileExisted", $FileExisted)
        _EzSkinMsgBox(262208, "Protect Folder", "The folder " & $sPath & ", was successfully locked!", -1, "", "", -1, -1, True)
    Else
        While 1
            $sPassword = _EzSkinInputBox("Unlock", "Enter password to unlock the folder: " & @CRLF & @CRLF & $sPath, "", "*")
            If @error Then Exit
            If _StringToHex($sPassword) <> $sSecurityKey Then
                If IsDeclared("sEZS_VERSION") Then
                    If _EzSkinMsgBox(262165, "Forgot your password?", "Enter the password again." & @CRLF & "Make sure to use uppercase and lowercase letters.", -1, "", "", -1, -1, True) = 4 Then ContinueLoop
                Else
                    If _EzSkinMsgBox(262165, "Forgot your password?", "Enter the password again." & @CRLF & "Make sure to use uppercase and lowercase letters.") = 4 Then ContinueLoop
                EndIf
                Exit
            EndIf
            ExitLoop
        WEnd
        $sOldCLSID = IniRead($sDesktopINI, "Security", "OldCLSID", "")
        If $sOldCLSID = "" Then
            IniDelete($sDesktopINI, ".ShellClassInfo", "CLSID")
        Else
            IniWrite($sDesktopINI, ".ShellClassInfo", "CLSID", $sOldCLSID)
        EndIf
        $iDropEffect = IniRead($sDesktopINI, "Security", "DefaultDropEffect", 0)
        If $iDropEffect = 0 Then
            IniDelete($sDesktopINI, ".ShellClassInfo", "DefaultDropEffect")
        Else
            IniWrite($sDesktopINI, ".ShellClassInfo", "DefaultDropEffect", $iDropEffect)
        EndIf
        If IniRead($sDesktopINI, "Security", "FileExisted", 1) = 0 Then
            FileDelete($sDesktopINI)
        Else
            IniDelete($sDesktopINI, "Security")
        EndIf
        If IsDeclared("sEZS_VERSION") Then
            _EzSkinMsgBox(262208, "Protect Folder", "The folder " & $sPath & ", was successfully unlocked!", -1, "", "", -1, -1, True)
        Else
            _EzSkinMsgBox(262208, "Protect Folder", "The folder " & $sPath & ", was successfully unlocked!")
        EndIf
    EndIf
    ; Mark it as hidden and system to ensure that it is hidden from normal users...
    FileSetAttrib($sDesktopINI, "+SH")
    ; Reset the attributs folder...
    FileSetAttrib($sPath, $sOldAttrib)
    Send("{F5}")
EndFunc   ;==>_ProtectFolder

Nice!!! Thanks...

The key: {2559a1f2-21d7-11d4-bdaf-00c04f60b9f0} is related to "Windows Security", see the code exported by Regedit:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\CLSID\{2559a1f2-21d7-11d4-bdaf-00c04f60b9f0}]
@="Windows Security"
"LocalizedString"="@explorer.exe,-7022"

[HKEY_CLASSES_ROOT\CLSID\{2559a1f2-21d7-11d4-bdaf-00c04f60b9f0}\DefaultIcon]
@=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\
  00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,73,00,68,00,\
  65,00,6c,00,6c,00,33,00,32,00,2e,00,64,00,6c,00,6c,00,2c,00,2d,00,34,00,38,\
  00,00,00

[HKEY_CLASSES_ROOT\CLSID\{2559a1f2-21d7-11d4-bdaf-00c04f60b9f0}\InProcServer32]
@=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\
  00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,73,00,68,00,\
  64,00,6f,00,63,00,76,00,77,00,2e,00,64,00,6c,00,6c,00,00,00
"ThreadingModel"="Apartment"

[HKEY_CLASSES_ROOT\CLSID\{2559a1f2-21d7-11d4-bdaf-00c04f60b9f0}\Instance]
"CLSID"="{3f454f0e-42ae-4d7c-8ea3-328250d6e272}"

[HKEY_CLASSES_ROOT\CLSID\{2559a1f2-21d7-11d4-bdaf-00c04f60b9f0}\Instance\InitPropertyBag]
"CLSID"="{13709620-C279-11CE-A49E-444553540000}"
"command"="@shell32.dll,-12707"
"method"="WindowsSecurity"

[HKEY_CLASSES_ROOT\CLSID\{2559a1f2-21d7-11d4-bdaf-00c04f60b9f0}\shellex]

[HKEY_CLASSES_ROOT\CLSID\{2559a1f2-21d7-11d4-bdaf-00c04f60b9f0}\shellex\ContextMenuHandlers]

[HKEY_CLASSES_ROOT\CLSID\{2559a1f2-21d7-11d4-bdaf-00c04f60b9f0}\shellex\ContextMenuHandlers\{2559a1f2-21d7-11d4-bdaf-00c04f60b9f0}]
@=""

[HKEY_CLASSES_ROOT\CLSID\{2559a1f2-21d7-11d4-bdaf-00c04f60b9f0}\shellex\MayChangeDefaultMenu]
@=""

[HKEY_CLASSES_ROOT\CLSID\{2559a1f2-21d7-11d4-bdaf-00c04f60b9f0}\ShellFolder]
"Attributes"=dword:00000000

http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!)

Somewhere Out ThereJames Ingram

somewh10.png

dropbo10.pngDownload Dropbox - Simplify your life!
Your virtual HD wherever you go, anywhere!

Link to comment
Share on other sites

Try this instead: {21EC2020-3AEA-1069-A2DD-08002B30309D}. This will actually turn your folder into a "shortcut to control panel".

Yes, But the icon of the padlock disappears :D

Appears the icon of the control panel...

However, it works well!

http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!)

Somewhere Out ThereJames Ingram

somewh10.png

dropbo10.pngDownload Dropbox - Simplify your life!
Your virtual HD wherever you go, anywhere!

Link to comment
Share on other sites

  • 2 years later...

Sorry for resurrecting the topic more precise protect folder on Linux too, is possible using autoit?

Edited by Belini
Link to comment
Share on other sites

Autoit actually create for Windows OS only, and i dont think, it will work on linux because linux use other executable file format.. all applicaton create by using Windows OS can't using in linux OS... You need to research more about different between other OS and Windows.. if you want to create application in linux, try to study in java, c or c++...download eclipse in linux because this application good for beginner in linux os.. ;).. i dont think so..

Edit :

Different animal, different part of body, different Os, different programming instruction..

Edited by knightz93

[font=verdana,geneva,sans-serif]I will do my best in this forum [/font][font=verdana,geneva,sans-serif]my code :[/font] WindowsSwitcher3d()

Link to comment
Share on other sites

The Windows did not lock folders in Linux, then the autoit also fails

Edited by Belini
Link to comment
Share on other sites

Can your version of Windows access the Linux file system at all?

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Linux can access files from Windows partitions and more Windows can not access anything Linux.

Files on Linux are more protected windows otherwise not happen.

Edited by Belini
Link to comment
Share on other sites

My point was, if your Windows can't see/access the Linux partitions, then AutoIt isn't going to magically make them appear.

As to whether or not Linux files are more protected, who cares, this is an AutoIt forum, and AutoIt doesn't work on Linux (without using WINE that is). If you want to use Linux use it, but don't expect a Windows only program to be able to be used with it.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

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...