Leaderboard
Popular Content
Showing content with the highest reputation on 04/06/2013 in all areas
-
Set Everyone write permission to a Registry key
q113960096 reacted to DmitryKa for a topic
Sometimes we need to save a piece of data for the whole machine globally, not for a current user only. Unfortunately HKEY_LOCAL_MACHINE is write-protected for anybody except administrators. But you may create e.g. a key "a_key" below HKEY_LOCAL_MACHINE with admin rights and then - assign "write-everybody" permission to "a_key", so unprivileged users will share the same data and will be allowed to modify it. The following function _RegSetKeySecuritySetNullDacl sets "write-everybody" permission to a Registry key. Usage sample: Local $szKey = "HKEY_LOCAL_MACHINE\SOFTWARE\YourCompany\a_key" Local $code, $msg Local $ok = _RegSetKeySecuritySetNullDacl($szKey, $code, $msg) If Not $ok Then MsgBox(0, "Exited with code " & $code, $msg) The library: #include-once #include <StructureConstants.au3> #include <WinAPIError.au3> #include <WinAPI.au3> ; ; Return value: ; 0 - failure ; 1 - success ; Func _RegSetKeySecuritySetNullDacl($szKey, ByRef $errorCode, ByRef $errorMessage) Local $hKey = 0 Local $ret = _RegSetKeySecuritySetNullDaclInternal($szKey, $hKey) If $hKey Then DllCall('AdvAPI32.dll', 'Long', 'RegCloseKey', "ulong_ptr", $hKey) If $ret Then If StringIsInt($ret) Then $errorCode = $ret $errorMessage = _WinAPI_GetErrorMessageByCode($ret) Else $errorCode = 1 $errorMessage = $ret EndIf Return 0 Else $errorCode = 0 $errorMessage = 0 Return 1 EndIf EndFunc ; ; Return values: ; 0 - success ; nnn - Windows error code ; "..." - error description ; Func _RegSetKeySecuritySetNullDaclInternal($szKey, ByRef $hKey) Local $HKEY_CLASSES_ROOT = 0x80000000 Local $HKEY_CURRENT_USER = 0x80000001 Local $HKEY_LOCAL_MACHINE = 0x80000002 Local $HKEY_USERS = 0x80000003 Local $HKEY_CURRENT_CONFIG = 0x80000005 ; Parse key hive. Local $hRoot = StringLeft($szKey, StringInStr($szKey, '\') - 1) If $hRoot = "" Then $hRoot = $szKey ; passed a root key Switch StringUpper($hRoot) Case "HKEY_LOCAL_MACHINE", "HKLM" $hRoot = $HKEY_LOCAL_MACHINE Case "HKEY_USERS", "HKU" $hRoot = $HKEY_USERS Case "HKEY_CURRENT_USER", "HKCU" $hRoot = $HKEY_CURRENT_USER Case "HKEY_CLASSES_ROOT", "HKCR" $hRoot = $HKEY_CLASSES_ROOT Case "HKEY_CURRENT_CONFIG", "HKCC" $hRoot = $HKEY_CURRENT_CONFIG Case Else Return "Unknown hive name: " & $hRoot EndSwitch Local $szSubkey = StringTrimLeft($szKey, StringInStr($szKey, '\')) If $szSubkey = $szKey Then $szSubkey = "" ; root key ; Open existed registry key. Local $aRet = DllCall( _ "advapi32.dll", "long", "RegOpenKeyExW", _ "ulong_ptr", $hRoot, _ "wstr", $szSubkey, _ "dword", 0, _ "ulong", 0x40000, _ ; WRITE_DAC "ulong_ptr*", 0 _ ) If @error Then Return "RegOpenKeyExW loading failed: @error=" & @error If $aRet[0] Then Return $aRet[0] $hKey = $aRet[5] ; The size of SECURITY_DESCRIPTOR is 20 bytes. We just ; need a block of memory the right size, we aren't going to ; access any members directly so it's not important what ; the members are, just that the total size is correct. Local $pSecurityAttributes = 0 Local $aRet = 0 Local $tSecurityDescriptor = DllStructCreate("dword[5]") Local $pSecurityDescriptor = DllStructGetPtr($tSecurityDescriptor) ; Initialize the security descriptor. $aRet = DllCall( _ "advapi32.dll", "bool", "InitializeSecurityDescriptor", _ "ptr", $pSecurityDescriptor, _ "dword", 1 _ ) If @error Then Return "InitializeSecurityDescriptor loading failed: @error=" & @error If Not $aRet[0] Then Return $aRet[0] ; Add the NULL DACL specifying access to everybody. $aRet = DllCall( _ "advapi32.dll", "bool", "SetSecurityDescriptorDacl", _ "ptr", $pSecurityDescriptor, _ "bool", 1, _ "ptr", 0, _ "bool", 0 _ ) If @error Then Return "SetSecurityDescriptorDacl loading failed: @error=" & @error If Not $aRet[0] Then Return $aRet[0] ; Set permissions. $aRet = DllCall( _ "Advapi32.dll", "long", "RegSetKeySecurity", _ "ulong_ptr", $hKey, _ "dword", BitOr(0x00000004, 0x80000000), _ "ptr", $pSecurityDescriptor _ ) If @error Then Return "RegSetKeySecurity loading failed: @error=" & @error If $aRet[0] Then Return $aRet[0] Return 0 EndFunc ; ; Convert Windows error code to message. ; Func _WinAPI_GetErrorMessageByCode($code) Local $tBufferPtr = DllStructCreate("ptr") Local $pBufferPtr = DllStructGetPtr($tBufferPtr) Local $nCount = _WinAPI_FormatMessage(BitOR($__WINAPICONSTANT_FORMAT_MESSAGE_ALLOCATE_BUFFER, $__WINAPICONSTANT_FORMAT_MESSAGE_FROM_SYSTEM), _ 0, $code, 0, $pBufferPtr, 0, 0) If @error Then Return SetError(@error, 0, "") Local $sText = "" Local $pBuffer = DllStructGetData($tBufferPtr, 1) If $pBuffer Then If $nCount > 0 Then Local $tBuffer = DllStructCreate("wchar[" & ($nCount+1) & "]", $pBuffer) $sText = DllStructGetData($tBuffer, 1) EndIf _WinAPI_LocalFree($pBuffer) EndIf Return $sText EndFunc ;==>_WinAPI_GetErrorMessageByCode1 point -
jerem488, Final change till you post again. I changed your msg loop to "switch' from "select" so that it works with a range of checkbox controls. The code writes a console mesage for whatever programm is checked. Beyond this, I have no idea what you are doing, assuming that this is even close. #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <EditConstants.au3> #include <ProgressConstants.au3> #include <Array.au3> $Fenetre_principale = GUICreate("Outils de sécurité", 300, 580) $Tailles_fenetre = WinGetPos("Outils de sécurité") $Label_enregistrement = GUICtrlCreateLabel("Dossier d'enregistrement : ", 10, 12, 150) GUICtrlSetFont($Label_enregistrement, 8.5, 600, 4) GUICtrlSetColor($Label_enregistrement, 0x007399) $Boutton_selection_dossier = GUICtrlCreateButton("Sélectionner", 165, 8, 87, 25) $Label_selection_dossier = GUICtrlCreateInput("", 10, 40, 280, 21) $Executer = GUICtrlCreateButton("Executer", $Tailles_fenetre[2] / 3 - 75, $Tailles_fenetre[3] - 69, 100) $Ouvrir_dossier = GUICtrlCreateButton("Ouvrir le dossier", $Tailles_fenetre[2] - $Tailles_fenetre[2] / 3 - 35, $Tailles_fenetre[3] - 69, 100) GUICtrlSetState($Executer, $GUI_DISABLE) GUICtrlSetState($Ouvrir_dossier, $GUI_DISABLE) ; changed the following array to 2D ; ; offset [0][0] = control id ; offset [0][1] = value Global $Array[6][2] $Array[0][1] = "Stinger" $Array[1][1] = "Spybot" $Array[2][1] = "Dr.Web CureIt!" $Array[3][1] = "Malwarebytes" $Array[4][1] = "AdwCleaner" $Array[5][1] = "Gmer" $Top = 70 ; 1st) ------------ For $i = 0 To UBound($Array, 1) - 1 $Array[$i][0] = GUICtrlCreateCheckbox($Array[$i][1], 10, $Top, 120) GUICtrlSetFont($Array, 8.5, 400, 4) GUICtrlCreateProgress(130, $Top, 128) GUICtrlCreateLabel("", 263, $Top, 37, 21, $SS_CENTERIMAGE) $Top += 25 ; changed this to display values in a 2D array ConsoleWrite('controlid = ' & $array[$i][0] & ' programm = ' & $array[$i][1] & @LF) Next GUISetState() Do ; changed your message loop to use switch $Action = GUIGetMsg() switch $Action Case $Boutton_selection_dossier $Selection_dossier = FileSelectFolder("Veuillez sélectionner l'emplacement des téléchargements :", @HomeDrive & "\") If @error <> 1 Then If StringRight($Selection_dossier, 1) <> "\" Then $Emplacement_des_telechargements = $Selection_dossier & "\__Programmes de sécurité__" Else $Emplacement_des_telechargements = $Selection_dossier & "__Programmes de sécurité__" EndIf GUICtrlSetData($Label_selection_dossier, $Emplacement_des_telechargements) GUICtrlSetState($Executer, $GUI_ENABLE) EndIf Case $Executer ;~ DirCreate($Emplacement_des_telechargements) ;~ GUICtrlSetState($Ouvrir_dossier, $GUI_ENABLE) Case $Ouvrir_dossier ShellExecute($Emplacement_des_telechargements) ; this is how you might check your checkboxes case $array[0][0] to $array[ubound($array,1)-1][0] for $1 = 0 to ubound($array,1) - 1 if guictrlread($array[$1][0]) = $gui_checked then ConsoleWrite('program = ' & $array[$1][1] & ' checked' & @LF) next EndSwitch Until $Action = $GUI_EVENT_CLOSE Func Stinger() EndFunc ;==>Stinger kylomas1 point
-
jerem488, Yes, just use the $SS_CENTERIMAGE style. When used together with the $SS_CENTER style, the text is centred in both axes. M231 point
-
How to Open Folder and Select File
hiepxuan2008 reacted to KaFu for a topic
Good to hear it worked .1 point -
Then it's the description from the file properties. You need something like this: ConsoleWrite(FileGetVersion("C:\Program Files (x86)\AutoIt3\AutoIt3.exe", "FileDescription") & @CRLF)1 point
-
Maybe this. #include <array.au3> Local $sTest = '<img src="/icons/text.gif" alt="[TXT]" width="20" height="22"> <a href="2757817%202691586%20Installation%20instructions.htm"> 2,757,817 2,691,586 Installation instructions . htm </ a>' & _ '<img width="20" height="22"> <a src="/icons/text.gif" alt="[TXT]" 2732618_readme.htm href="2790817%202732618_readme.htm"> 2790817 </a>' & _ '<img width="20" height="22"> <a src="/icons/text.gif" alt="[TXT]" href="942146.reg"> 942146.reg </a>' & _ '<img src="/icons/text.gif" alt="[TXT]" width="20" height="22"> <a href="Windows6.1-KB2757817-x64%20Installation%20instructions.htm"> Windows6.1-KB2757817-x64 Installation instructions.htm </a>' & _ '<img src="/icons/text.gif" alt="[TXT]" width="20" height="22"> <a href="Windows6.1-KB976932-x64.html"> Windows6.1-KB976932-x64.html </a>' Local $aArray = StringRegExp(StringReplace($sTest, "%20", " "), 'href="([^"]+)"', 3) _ArrayDisplay($aArray)1 point
-
hodahel, I think water is saying that the "if error" stmt can use continue loop. I am writing a message to the console then falling through (which continues the loop). The choice is yours. kylomas1 point
-
Updated version of File hider.....New feather is a forgot button click on it if you forgot your hide file name.... ;File Hider #include #include $Dir=":\" $FilehideGui = GUICreate("File Hider", 287, 190, 193, 115) $lblDrivename= GUICtrlCreateLabel("Drive Name:", 16, 40, 60, 17);Drive name in which your Folder save that you want Hide. $lblFoldername = GUICtrlCreateLabel("Folder/File Name:", 16, 80, 95, 17);Folder name or file name that you want hide.if your,s specific folder is present in another folder you can write his name as(Folder\folder1\folder2\etc) $txtdrivename = GUICtrlCreateInput("", 112, 40, 153, 21) $lblInfo = GUICtrlCreateLabel("Don't worry if you forgot your hide file name!", 35, 8, 250, 20) GUICtrlSetFont($lblInfo, 8, 800) $btnOK3 = GUICtrlCreateButton("&Forgot!", 170, 115, 75, 25, 0) GUICtrlCreateLabel("If you forgot your hide file name!", 16, 120, 155, 20) Dim $ES_PA,$ES_AU $txtFoldername = GUICtrlCreateInput("", 112, 80, 153, 21, BitOR($ES_PA,$ES_AU)) $btnOK = GUICtrlCreateButton("&Hide!", 200, 160, 75, 25, 0) $btnOK2 = GUICtrlCreateButton("&Show!", 120, 160, 75, 25, 0) $lblInfo3 = GUICtrlCreateLabel("AdnanBaloch", 10, 164, 110, 80) GUICtrlSetFont($lblInfo3, 12, 800) GUISetState(@SW_SHOW) While 1 $uMsg = GUIGetMsg() Switch $uMsg Case $btnOK $Drivename = GUICtrlRead($txtdrivename) If StringLen($Drivename)=0 Then MsgBox(64,"AdnanBaloch","Plese Enter Your Drivername.") Else $Foldername = GUICtrlRead($txtFoldername) If StringLen($Foldername)=0 Then MsgBox(64,"HM_LINK 03216592390","Plese Enter Your Folder or File name.") Else $Drivename = GUICtrlRead($txtDrivename) $Foldername = GUICtrlRead($txtFoldername) Run("CMD") Sleep(500) Send("attrib {+}s {+}h ") Send($Drivename&$Dir&$Foldername) Sleep(250) Send("{Enter}") Send("{Enter}") sleep(250) Send("exit") Send("{Enter}") ExitLoop EndIf EndIf Case $btnOK2 $Drivename = GUICtrlRead($txtdrivename) If StringLen($Drivename)=0 Then MsgBox(64,"AdnanBaloch","Plese Enter Your Drivername.") Else $Foldername = GUICtrlRead($txtFoldername) If StringLen($Foldername)=0 Then MsgBox(64,"HM_LINK 03216592390","Plese Enter Your Folder or File name.") Else $Drivename = GUICtrlRead($txtDrivename) $Foldername = GUICtrlRead($txtFoldername) Run("CMD") Sleep(500) Send("attrib {-}s {-}h ") Send($Drivename&$Dir&$Foldername) Sleep(250) Send("{Enter}") Send("{Enter}") sleep(250) Send("exit") Send("{Enter}") ExitLoop EndIf EndIf case $btnOK3 $DD=":" $dir="dir/a" $Drivename = GUICtrlRead($txtDrivename) $Foldername = GUICtrlRead($txtFoldername) If StringLen($Drivename)=0 Then MsgBox(64,"AdnanBaloch","Plese Enter Your Drivername.") Else Run("CMD") Sleep(500) Send($Drivename&$DD) Send("{Enter}") Send("{Enter}") Send($dir) Sleep(250) Send("{Enter}") Send("{Enter}") Sleep(250) MsgBox(64,"Find file Name","find your file name and mark it with the help of right click and copy by ctr+c then paste it in folder/file name.") ExitLoop EndIf Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd GUISetState(@SW_HIDE) MsgBox(64,"Can you like me?","If you like this please give me a 'Like'On Post")1 point
-
thanks PainTain and enjoy your first "Like"1 point
-
thanks Ksr....1 point
-
Thanks james with the help of friends it will be better more.......1 point