Sign in to follow this  
Followers 0
forever0donotknowme

I cache some idea from another topic

2 posts in this topic

hi my friends,

please can you check next link

i want to know if there is any dos command that perform same work / disable access to folder or file

Share this post


Link to post
Share on other sites



You can probably try using icacles or cacles, I forget the name and I think I remember it would be used to mess with permissions for a file just like TakeOwn command in vista and win 7.

Here's something that should work on winxp, but it doesn't use dos commands.

If Not @OSVersion == "WIN_XP" Then MsgBox(16, "Warning!", "This is pretty useless on anything that isn't Windows XP.")

If Not AdjustPrivilege(8) Then MsgBox(0, "", "Error!")
If Not AdjustPrivilege(9) Then MsgBox(0, "", "Error!")
If Not AdjustPrivilege(20) Then MsgBox(0, "", "Error!")

Global Const $hADVAPI32 = DllOpen("advapi32.dll")
Global Const $hKERNEL32 = DllOpen("kernel32.dll")

; ## FUNCTION ## ================================================================================================
; Name ..........: _TakeOwn
; Description ...: Grants or denies access to the current user for a file or directory
; Syntax ........: _ModOwner ($oName , $DenyAccess)
; Parameters ....: $oName - directory or file path.
;                  $DenyAccess - True or False, 0 to deny access, 1 to grant access.
; Return values .: 1 if it worked, 0 if it did not.
; Author ........: Fred (FredAI)
; Modified ......: ApudAngelorum aka CaptainClucks
; Remarks .......: This code was originally a huge library UDF by Fred (FredAI), all I did was make it into a
;                  Simplified function for what I needed.
; Example .......: Nope...
; ===============================================================================================================

Func _TakeOwn($oName, $DenyAccess)

    Local $_TRUSTEE_TYPE = 1
    Local $_EXPLICIT_ACCESS
    Local $GENERIC_ALL = 0x10000000

    Local $SE_FILE_OBJECT = 1
    Local $ACL_REVISION = 2

Local $AccessMode = 3;grant access to current user
If $DenyAccess Then $AccessMode = 2; deny access

    $_EXPLICIT_ACCESS = DllStructCreate('DWORD;DWORD;DWORD;ptr;DWORD;DWORD;DWORD;ptr')

    Local $tData = DllStructCreate("byte SID[256]")
    Local $pSID = DllStructGetPtr($tData, "SID")
    Local $aResult = DllCall("Advapi32.dll", "bool", "LookupAccountNameW", "wstr", '', "wstr", @UserName, "ptr", $pSID, "dword*", 256, "wstr", "", "dword*", 256, "int*", 0)
    If @error Then Return SetError(1, 0, 0)

    Local $aResult = DllCall("Advapi32.dll", "bool", "IsValidSid", "ptr", $pSID)
    If @error Or Not $aResult[0] Then Return SetError(2, 0, 0)

    Local $aResult = DllCall("Advapi32.dll", "int", "ConvertSidToStringSidW", "ptr", $pSID, "ptr*", 0)
    If @error Or Not $aResult[0] Then Return SetError(3, 0, "")
    Local $tBuffer = DllStructCreate("wchar Text[256]", $aResult[2])
    Local $sSID = DllStructGetData($tBuffer, "Text")
    DllCall("Kernel32.dll", "ptr", "LocalFree", "ptr", $aResult[2])

    Local $aResult = DllCall("Advapi32.dll", "bool", "ConvertStringSidToSidW", "wstr", $sSID, "ptr*", 0)
    If @error Or Not $aResult[0] Then Return SetError(4, 0, 0)
    Local $aResult2 = DllCall("Advapi32.dll", "dword", "GetLengthSid", "ptr", $aResult[2])
    If @error Then Return SetError(5, 0, 0)

    Local $iSize = $aResult2[0]
    Local $tBuffer = DllStructCreate("byte Data[" & $iSize & "]", $aResult[2])
    Local $tSID = DllStructCreate("byte Data[" & $iSize & "]")
    DllStructSetData($tSID, "Data", DllStructGetData($tBuffer, "Data"))
    DllCall("Kernel32.dll", "ptr", "LocalFree", "ptr", $aResult[2])

    $pUSERSID = DllStructGetPtr($tSID)
    DllStructSetData($_EXPLICIT_ACCESS, 1, $GENERIC_ALL);grfAccessPermissions
    DllStructSetData($_EXPLICIT_ACCESS, 2, $AccessMode);grfAccessMode
    DllStructSetData($_EXPLICIT_ACCESS, 3, 3);grfInheritance
    DllStructSetData($_EXPLICIT_ACCESS, 6, 0);TrusteeForm = $TRUSTEE_IS_SID = 0

    Local $aCall = DllCall("Advapi32.dll", 'BOOL', 'LookupAccountSid', 'ptr', 0, 'ptr', $pUSERSID, 'ptr*', 0, 'dword*', 32, 'ptr*', 0, 'dword*', 32, 'dword*', 0)
    If Not @error Then $_TRUSTEE_TYPE = $aCall[7]
    DllStructSetData($_EXPLICIT_ACCESS, 7, $_TRUSTEE_TYPE);TrusteeType
    DllStructSetData($_EXPLICIT_ACCESS, 8, $pUSERSID);Pointer to the SID

    Local $p_EXPLICIT_ACCESS = DllStructGetPtr($_EXPLICIT_ACCESS)
    $aCall = DllCall("Advapi32.dll", 'DWORD', 'SetEntriesInAcl', 'ULONG', 1, 'ptr', $p_EXPLICIT_ACCESS, 'ptr', 0, 'ptr*', 0)
    If @error Or $aCall[0] Then Return SetError(6, 0, 0)

    Local $DACL = $aCall[4]
    Local $SECURITY_INFORMATION = 4

    Local $aResult = DllCall("Advapi32.dll", "bool", "IsValidSid", "ptr", $pUSERSID)
    If @error Or Not $aResult[0] Then Return SetError(7, 0, 0)

    If $pUSERSID Then
        $SECURITY_INFORMATION = 5
    Else
        $pUSERSID = 0
    EndIf

    Local $Buffer = DllStructCreate('byte[32]')
    DllCall("Advapi32.dll", 'bool', 'InitializeAcl', 'Ptr', DllStructGetPtr($Buffer, 1), 'dword', DllStructGetSize($Buffer), 'dword', $ACL_REVISION)
    DllCall("Advapi32.dll", 'DWORD', 'SetNamedSecurityInfo', 'str', $oName, 'dword', $SE_FILE_OBJECT, 'DWORD', 4, 'ptr', 0, 'ptr', 0, 'ptr', 0, 'ptr', 0)
    Local $aRet = DllCall("Advapi32.dll", 'DWORD', 'SetNamedSecurityInfo', 'str', $oName, 'dword', $SE_FILE_OBJECT, 'DWORD', 4, 'ptr', 0, 'ptr', 0, 'ptr', DllStructGetPtr($Buffer, 1), 'ptr', 0)
    If @error Then Return SetError(8, 0, 0)

    $aCall = DllCall("Advapi32.dll", 'dword', 'SetNamedSecurityInfo', 'str', $oName, 'dword', $SE_FILE_OBJECT, _
            'dword', $SECURITY_INFORMATION, 'ptr', $pUSERSID, 'ptr', 0, 'ptr', $DACL, 'ptr', 0)
    If @error Then Return SetError(9, 0, 0)
    Return SetError(0, 0, 0)
EndFunc

Func AdjustPrivilege($Type); Originally by forum user Manko of autoitscript.com
    Local $aReturn = DllCall("ntdll.dll", "int", "RtlAdjustPrivilege", "int", $Type, "int", 1, "int", 0, "int*", 0)
    If @error Or $aReturn[0] Then Return SetError(1, 0, 0)
    Return SetError(0, 0, 1)
EndFunc   ;==>AdjustPrivilege

Things that I've done..

Icon Resource Editor: icon resource editor 

AutoIt Piano: a piano

AutoIt Unlocker: unlocks files when you want to delete them

Colorful tooltips: a wrapper for the tool tips UDF

Rouge GoogleBot: a full screen animation

ASciTE text editor: a text editor written in autoit

Warning: Posts by this user are subject to change or may disappear without notice.

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

  • Similar Content

    • Dequality
      By Dequality
      Can anyone tell me if its possible to make autoit search for text? (im trying to search for a button a pop up(the color changes every time so i cant use img search) so i thought why not try using text search if possible) , the text is following: 'OK', 'Okay', 'Tak', 'Fedt'.
      I've searched around most possibilities i found was img search which doesnt work cuz of the color change.. ^^
      Any help are HIGHLY appreciatet.
      -Dequality.
    • DiveHigh
      By DiveHigh
      Hello There!  
      I've encountered a small issue i just cant seem to program my way out of...

      What im doing is:        ;or rather, what im trying to do is
      Pixelsearch for a color, within a part of my screen,
      If color is present, i will rightclick it, for a menu to appear,
      in which i want to Leftclick an option. Simplicity itself.   

      The issue is that because this menu appears in different parts of my screen, its complicated to select the option i want to click.
      There is no special color to it, and i cannot define the area in which to click, because the menu appears different places.
      The only thing that is in common for the menu is that the Leftclick needs to be (lets say) 30pixels below the rightclick
      .

      What can be done,  but seemingly not by me, is to get the coordinates of the rightclick, and use them as the "starting point" from where the coordinates for the leftclick will be.
      (Not sure if that makes sence, but maybe the code below will help you understand)

      You guys like example codes, so therefore i will give it my best shot, and hope it proves usefull

      $pos = Pixelsearch(200, 400, 200, 400, 0xFFFFFF)        ;This color is what i need to rightclick to bring up the menu
      If not @Error then                                                               ;If the color is present
      (Mouseclick("Right", $pos[0], $pos[1], 1, 1)                   ;Rightclick it, to bring up menu
      ;Here comes the part i cannot get to work
      $x = MousegetPos(X)                                                          ;To get the Coordinate "X", so we can calculated with it for the position of the leftclick
      $y = MousegetPos(Y)                                                           ; To get the Coordinate "Y", so that can be calculated with for the position of the leftclick

      MouseClick("Left", $x[0], $y-30[1], 1, 1)                         ;This was supposed to give me a leftclick that is 30pixels below the rightclick.
      (The MouseGetPos(X), may seem as a waste of space in this example, but in my script i will need both. 
              Im only using one in the example, mainly so that i wont confuse myself, but also to make it easier to digest for you guys)


      I have not been able to find any topic that covers this, but my apologies if such a topic already exist in the forums. 

      Maybe while im at it, can i ask,   what good does the [0] and [1] do, when using a "$variable" as coordinate?   


      Thanks in advance
      - DiveHigh
    • galan2015
      By galan2015
      yo, i need some help.

      Im training with _StringsBetween, on big site! Alot fun, My script turned 8 times created a text file with a weight of 1GB. I saw that in the file was a lot of repetition. Is it possible to somehow set the string to save the file, only one URL without repetition?
      #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <INet.au3> #include <StringConstants.au3> #include <File.au3> ;I'm coming for blood, no code of conduct, no law. ;I'm coming for blood, no code of conduct, no law. #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 1211, 812, 43, 110) $Button1 = GUICtrlCreateButton("Button1", 0, 8, 249, 81) $Button2 = GUICtrlCreateButton("Button2", 350, 8, 249, 81) $Edit1 = GUICtrlCreateEdit("0", 8, 128, 609, 257, BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_READONLY,$ES_WANTRETURN)) $Edit2 = GUICtrlCreateEdit("2", 632, 0, 577, 809) GUISetState(@SW_SHOW) #EndRegion ### END Koda local $iFileSize = FileGetSize('') Func VisitFrontPage() local $Liczba = _FileCountLines(@ScriptDir&'\data\links.txt') local $liczba2 = GUICtrlSetData($Edit1,Random(1,$Liczba,1)) local $Liczba3 = GUICtrlRead($Edit1) local $Liczba4 = FileReadLine(@ScriptDir&'\data\links.txt',$Liczba3) $data = _INetGetSource ( FileReadLine(@ScriptDir&'\data\links.txt',Random(1,$Liczba,1))) $linki = StringRegExp($data, '<a href="http://www.wykop.pl/link/(.*?)/" title=""',3) For $q = 0 To UBound($linki) -1 FileWrite(@ScriptDir&'\data\links.txt','http://www.wykop.pl/link/'&$linki[$q]&@CRLF) Next $linki = StringRegExp($data, 'href="http://www.wykop.pl/ludzie/(.*?)/">',3) ; pobieranie ludzi co dodali znaleziska For $w = 0 To UBound($linki) -1 FileWrite(@ScriptDir&'\data\links.txt','http://www.wykop.pl/ludzie/'&$linki[$w]&@CRLF) Next $linki = StringRegExp($data, '<a href="http://www.wykop.pl/ludzie/(.*?)/" title="',3) ; pobieranie ludzi co sa na stronie z mikro For $e = 0 To UBound($linki) -1 FileWrite(@ScriptDir&'\data\links.txt','http://www.wykop.pl/ludzie/'&$linki[$e]&@CRLF) Next $linki = StringRegExp($data, '<a class="tag create" href="http://www.wykop.pl/tag/(.*?)/"><em>',3) ; pobieranie ludzi co sa na stronie z mikro For $r = 0 To UBound($linki) -1 FileWrite(@ScriptDir&'\data\links.txt','http://www.wykop.pl/tag/'&$linki[$r]&@CRLF) Next $linki = StringRegExp($data, '<class="showTagSummary" href="http://www.wykop.pl/tag/(.*?)">',3) ; pobieranie ludzi co sa na stronie z mikro For $t = 0 To UBound($linki) -1 FileWrite(@ScriptDir&'\data\links.txt','http://www.wykop.pl/tag/'&$linki[$t]&@CRLF) Next $linki = StringRegExp($data, 'href="http://www.wykop.pl/ludzie/(.*?)/" title=""',3) ; pobieranie ludzi z znaleziska, komentarze For $a = 0 To UBound($linki) -1 FileWrite(@ScriptDir&'\data\links.txt','http://www.wykop.pl/ludzie/'&$linki[$a]&@CRLF) Next $linki = StringRegExp($data, 'href="http://www.wykop.pl/tag/index/(.*?)/"',3) ; pobierane tagi ze znaleziska, For $s = 0 To UBound($linki) -1 FileWrite(@ScriptDir&'\data\links.txt','http://www.wykop.pl/tag/index/'&$linki[$s]&@CRLF) Next $linki = StringRegExp($data, '<a class="clearfix" href="http://www.wykop.pl/link/(.*?)/?utm_source',3) ; pobierane znaleziska z prawego menu For $d = 0 To UBound($linki) -1 FileWrite(@ScriptDir&'\data\links.txt','http://www.wykop.pl/link/'&$linki[$d]&@CRLF) Next Sleep(5000) GuiCtrlSetData($Edit2, GuiCtrlRead($Edit2)+1) _FileWriteToLine(@ScriptDir&'\data\links.txt',GuiCtrlRead($edit1),'',1) VisitFrontPage() EndFunc While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $Button1 Case $Button2 VisitFrontPage() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd  
    • Tuurngait
      By Tuurngait
      Okay so basically I have another problem with my script again, Not exactly the script it's self but more finding how to add a certain pixel color into it. I've made a few attempts and got it close but not close enough. I'm trying to make the mouse hover over the Pause Button on my Media Player. I'll add the Pixel color into the attachments. If someone could show me how to find the Pixel color in the form of the line "PixelSearch( 0, 0, $i, 768, 0xFF0000, 10 )" then I'd be the most greatful noobie that ever existed
      misc4.au3