Jump to content
Sign in to follow this  
GHOSTSKIKDA

Hide Files System in Removable

Recommended Posts

GHOSTSKIKDA

Hey guys,

I'm trying to use the delete files same time in Removable or change attrib to show.

ex: delete : Autorun.inf ===> Attrib = SH in Removable

this is try me :

#cs ----------------------------------------------------------------------------
AutoIt Version: 3.3.6.1
Author:      GHOST SKIKDA
Script Function:
    Hide Files System in Removable.
#ce ----------------------------------------------------------------------------
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <GuiStatusBar.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 554, 454, 192, 114)
GUISetBkColor(0x000000)
$ListView1 = GUICtrlCreateListView("Name|Status", 16, 168, 522, 270, '', BitOR($WS_EX_CLIENTEDGE,$LVS_EX_GRIDLINES))
_GUICtrlListView_SetExtendedListViewStyle(-1, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES))
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 400)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 100)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x00FF00)
GUICtrlSetBkColor(-1, 0x800000)
$ListView1context = GUICtrlCreateContextMenu($ListView1)
$MenuItem1 = GUICtrlCreateMenuItem("Show", $ListView1context)
$MenuItem2 = GUICtrlCreateMenuItem("Hide", $ListView1context)
$MenuItem3 = GUICtrlCreateMenuItem("Delete", $ListView1context)
$Button1 = GUICtrlCreateButton("Scan", 462, 134, 75, 25, $WS_GROUP)
$Combo1 = GUICtrlCreateCombo("", 50, 136, 409, 25)
$Label1 = GUICtrlCreateLabel("Path : ", 16, 139, 35, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
$StatusBar1 = _GUICtrlStatusBar_Create($Form1)
Dim $StatusBar1_PartsWidth[1] = [-1]
_GUICtrlStatusBar_SetParts($StatusBar1, $StatusBar1_PartsWidth)
_drivercombo()
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            _GUICtrlListView_DeleteAllItems($ListView1)
            Sleep(200)
            ;Search("f:\")
            _driver()
        Case $ListView1
    EndSwitch
WEnd
 
;~ Func _Search()
;~  $search = FileFindFirstFile("C:\*.*")
;~ If $search = -1 Then
;~   MsgBox(0, "Error", "No files/directories matched the search pattern")
;~   Exit
;~ EndIf
;~ $com=0
;~ While 1
;~   $file = FileFindNextFile($search)
;~   If @error Then ExitLoop
;~  $var = FileGetAttrib("C:\"&$file)
;~  If ($var = "RASH") or ($var = "SH") Then
;~    _GUICtrlListView_AddItem($ListView1, $file, $com)
;~    _GUICtrlListView_AddSubItem($ListView1, $com,$var, 1)
;~    ;_GUICtrlListView_SetItemChecked($ListView1, $com)
;~    $com=$com+1
;~  EndIf
;~ WEnd
;~ FileClose($search)
;~ _GUICtrlStatusBar_SetText($StatusBar1, @TAB & "Resultat =  " & _GUICtrlListView_GetItemCount($ListView1), 0)
;~ EndFunc
Func Search($current)
Local $search = FileFindFirstFile($current & "\*.*")
$com=0
While 1
Dim $file = FileFindNextFile($search)
If @error Or StringLen($file) < 1 Then ExitLoop
$var = FileGetAttrib($current &"\"&$file)
If ($var = "RASH") or ($var = "SH") or ($var = "RAH") or ($var = "ASH") Then;StringInStr(FileGetAttrib($current & "\" & $file), "D") And ($file <> "." Or $file <> "..") and
    _GUICtrlListView_AddItem($ListView1, $file, $com)
    _GUICtrlListView_AddSubItem($ListView1, $com,$var, 1)
        ;_GUICtrlListView_SetItemChecked($ListView1, $com)
    $com=$com+1
    Search($current & "\" & $file)
EndIf
Sleep (1)
_GUICtrlStatusBar_SetText($StatusBar1, @TAB & "Resultat =  " & _GUICtrlListView_GetItemCount($ListView1), 0)
WEnd
EndFunc
Func _driver()
    $drv = DriveGetDrive( "Removable")
If NOT @error Then
    For $i = 2 to $drv[0]
        GUICtrlSetData($Combo1,$drv[$i])
        Search($drv[$i])
    Next
EndIf
EndFunc
 
Func _drivercombo()
    $drv = DriveGetDrive( "Removable")
If NOT @error Then
    For $i = 2 to $drv[0]
        GUICtrlSetData($Combo1,$drv[$i])
    Next
EndIf
EndFunc

Posted Image

post-32527-0-21616400-1317762043_thumb.j


[center]I LOVE ALGERIA .... ;-)[/center]

Share this post


Link to post
Share on other sites
GHOSTSKIKDA
:graduated:

[center]I LOVE ALGERIA .... ;-)[/center]

Share this post


Link to post
Share on other sites
KaFu
GHOSTSKIKDA

Please rephrase your question as I do not understand it.

Okey

I want to put code to delete all the selected files.

Edited by ALG

[center]I LOVE ALGERIA .... ;-)[/center]

Share this post


Link to post
Share on other sites
GHOSTSKIKDA

and now, :graduated:


[center]I LOVE ALGERIA .... ;-)[/center]

Share this post


Link to post
Share on other sites
GHOSTSKIKDA

As long as you can't make clear what you want, and maybe even in this case why you want it, you wont get much responses.

Jos

I want to delete hidden files within the removable, but after the selected

Now clear ?


[center]I LOVE ALGERIA .... ;-)[/center]

Share this post


Link to post
Share on other sites
KaFu

There are several issues with your script.

- your Search function is recursive to an unlimited depth, which will take some time on large drives

- the listview only contains the filenames without a driveletter, in the _driver() function you parse through $i = 2 To $drv[0] removable drives (why 2?) and trigger the search function => if you have more than 1 drive in your list you can not say on which drive the file in the listview is afterwards. Better add the driveletter to the filename in the listview too.

- a sleep in the search function will slow down the search dramatically

- Here is a snippet of pseudo-code to inspire you how to delete only the checked files.

Case $MenuItem3
            For $i = 1 To _GUICtrlListView_GetItemCount($hListView)
                If _GUICtrlListView_GetItemChecked($hListView, $i - 1) Then ; LV has 0-based index
                    ; fileattrib -R
                    ; delete _GUICtrlListView_GetItemText($hListView, $i - 1)
                EndIf
            Next

also add Global $hListView = GUICtrlGetHandle($ListView1) at the top to get the handle for the LV.

Share this post


Link to post
Share on other sites
GHOSTSKIKDA

Thank you my friend KaFu

this code: $ i = 2 To $ drv [0] does not appear the floppy disk reader

try for yourself the full code

I added your code :

#cs ----------------------------------------------------------------------------
 AutoIt Version: 3.3.6.1
 Author:         GHOST SKIKDA
 Script Function:
 Hide Files System in Removable.
#ce ----------------------------------------------------------------------------
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <GuiStatusBar.au3>
#include <File.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 554, 454, 192, 114)
GUISetBkColor(0x000000)
$ListView1 = GUICtrlCreateListView("Name|Status", 16, 168, 522, 270, '', BitOR($WS_EX_CLIENTEDGE,$LVS_EX_GRIDLINES))
_GUICtrlListView_SetExtendedListViewStyle(-1, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES))
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 400)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 100)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x00FF00)
GUICtrlSetBkColor(-1, 0x800000)
$ListView1context = GUICtrlCreateContextMenu($ListView1)
$MenuItem1 = GUICtrlCreateMenuItem("Show", $ListView1context)
$MenuItem2 = GUICtrlCreateMenuItem("Hide", $ListView1context)
$MenuItem3 = GUICtrlCreateMenuItem("Delete", $ListView1context)
$Button1 = GUICtrlCreateButton("Scan", 462, 134, 75, 25, $WS_GROUP)
$Combo1 = GUICtrlCreateCombo("", 50, 136, 409, 25)
$Label1 = GUICtrlCreateLabel("Path : ", 16, 139, 35, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
$StatusBar1 = _GUICtrlStatusBar_Create($Form1)
Dim $StatusBar1_PartsWidth[1] = [-1]
_GUICtrlStatusBar_SetParts($StatusBar1, $StatusBar1_PartsWidth)
_drivercombo()
Global $hListView = GUICtrlGetHandle($ListView1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
 $nMsg = GUIGetMsg()
 Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
  Case $Button1
   _GUICtrlListView_DeleteAllItems($ListView1)
   Sleep(200)
   ;Search("f:\")
   _driver()
  Case $ListView1
  Case $MenuItem1
   For $i = 1 To _GUICtrlListView_GetItemCount($ListView1)
                If _GUICtrlListView_GetItemChecked($hListView, $i - 1) Then ; LV has 0-based index
     FileSetAttrib(GUICtrlRead($Combo1)&"\"&_GUICtrlListView_GetItemText($hListView, $i - 1),"-RASH")
                EndIf
            Next
  Case $MenuItem2
   For $i = 1 To _GUICtrlListView_GetItemCount($ListView1)
                If _GUICtrlListView_GetItemChecked($hListView, $i - 1) Then ; LV has 0-based index
     FileSetAttrib(GUICtrlRead($Combo1)&"\"&_GUICtrlListView_GetItemText($hListView, $i - 1),"+RASH")
                EndIf
            Next
  Case $MenuItem3
            For $i = 1 To _GUICtrlListView_GetItemCount($ListView1)
                If _GUICtrlListView_GetItemChecked($hListView, $i - 1) Then ; LV has 0-based index
                    ; fileattrib -R
                    ;delete_GUICtrlListView_GetItemText($hListView, $i - 1)
     MsgBox(0,"",GUICtrlRead($Combo1)&"\"&_GUICtrlListView_GetItemText($hListView, $i - 1))
     FileSetAttrib(GUICtrlRead($Combo1)&"\"&_GUICtrlListView_GetItemText($hListView, $i - 1),"-RASH")
     FileDelete(GUICtrlRead($Combo1)&"\"&_GUICtrlListView_GetItemText($hListView, $i - 1))
                EndIf
            Next
 EndSwitch
WEnd
Func Search($current)
Local $search = FileFindFirstFile($current & "\*.*")
$com=0
While 1
Dim $file = FileFindNextFile($search)
If @error Or StringLen($file) < 1 Then ExitLoop
$var = FileGetAttrib($current &"\"&$file)
If ($var = "RASH") or ($var = "SH") or ($var = "RAH") or ($var = "ASH") or ($var = "RHS")Then;StringInStr(FileGetAttrib($current & "\" & $file), "D") And ($file <> "." Or $file <> "..") and
 _GUICtrlListView_AddItem($ListView1, $file, $com)
 _GUICtrlListView_AddSubItem($ListView1, $com,$var, 1)
  ;_GUICtrlListView_SetItemChecked($ListView1, $com)
 $com=$com+1
 Search($current & "\" & $file)
EndIf
Sleep (1)
_GUICtrlStatusBar_SetText($StatusBar1, @TAB & "Resultat =  " & _GUICtrlListView_GetItemCount($ListView1), 0)
WEnd
EndFunc
Func _driver()
 $drv = DriveGetDrive( "Removable")
If NOT @error Then
 For $i = 2 to $drv[0]
  GUICtrlSetData($Combo1,$drv[$i])
  Search($drv[$i])
 Next
EndIf
EndFunc

Func _drivercombo()
 $drv = DriveGetDrive( "Removable")
If NOT @error Then
 For $i = 2 to $drv[0]
  GUICtrlSetData($Combo1,$drv[$i])
 Next
EndIf
EndFunc

[center]I LOVE ALGERIA .... ;-)[/center]

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  

  • Similar Content

    • kristo
      By kristo
      The DriveGetDrive command returned all drives (option "ALL") for years now and my program could always rely on that function. Suddenly a drive letter that was created with the subst command does not appear in the list of drives anymore. And it clearly did, because I used to react to a certain subst command by reacting to new or revoked (subst /D) drive letters.
      Why is that? I think this a bug because there's no way left to list ALL drive letters anymore.
      And why should I use an API command for that when this was already built in for years?

       
    • jguinch
      By jguinch
      Hello.
      I did create these few functions several months ago. I post here, if it can interest someone.
      These functions based on WMI queries allow you to manage printers : add / delete printer, driver, port, or obtain configuration, set default printer ... I let you discover it with the code.

       
      Here is the list of the available functions :
      _Printmgr_AddLocalPort
      _Printmgr_AddLPRPort
      _PrintMgr_AddPrinter
      _PrintMgr_AddPrinterDriver
      _PrintMgr_AddTCPIPPrinterPort
      _PrintMgr_AddWindowsPrinterConnection
      _PrintMgr_CancelAllJobs
      _Printmgr_EnumPorts
      _PrintMgr_EnumPrinter
      _PrintMgr_EnumPrinterConfiguration
      _PrintMgr_EnumPrinterDriver
      _PrintMgr_EnumPrinterProperties
      _PrintMgr_EnumTCPIPPrinterPort
      _Printmgr_Pause
      _Printmgr_PortExists
      _Printmgr_PrinterExists
      _Printmgr_PrinterSetComment
      _Printmgr_PrinterSetDriver
      _Printmgr_PrinterSetPort
      _Printmgr_PrinterShare
      _Printmgr_PrintTestPage
      _PrintMgr_RemoveLocalPort
      _PrintMgr_RemoveLPRPort
      _PrintMgr_RemovePrinter
      _PrintMgr_RemovePrinterDriver
      _PrintMgr_RemoveTCPIPPrinterPort
      _PrintMgr_RenamePrinter
      _Printmgr_Resume
      _PrintMgr_SetDefaultPrinter
       
      And some examples :
      #Include "PrintMgr.au3" ; Remove a printer called "My old Lexmark printer" : _PrintMgr_RemovePrinter("My old Lexmark printer") ; Remove the driver called "Lexmark T640" : _PrintMgr_RemovePrinterDriver("Lexmark T640") ; Remove the TCP/IP printer port called "TCP/IP" _PrintMgr_RemoveTCPIPPrinterPort("MyOLDPrinterPort") ; Add a driver, called "Samsung ML-451x 501x Series", and driver inf file is ".\Samsung5010\sse2m.inf" _PrintMgr_AddPrinterDriver("Samsung ML-451x 501x Series", "Windows NT x86", @scriptDir & "\Samsung5010", @scriptDir & "\Samsung5010\sse2m.inf") ; Add a TCP/IP printer port, called "MyTCPIPPrinterPort", with IPAddress = 192.168.1.10 and Port = 9100 _PrintMgr_AddTCPIPPrinterPort("MyTCPIPPrinterPort", "192.168.1.10", 9100) ; Add a printer, give it the name "My Printer", use the driver called "Samsung ML-451x 501x Series" and the port called "MyTCPIPPrinterPort" _PrintMgr_AddPrinter("My Printer", "Samsung ML-451x 501x Series", "MyTCPIPPrinterPort") ; Set the printer called "My Printer" as default printer _PrintMgr_SetDefaultPrinter("My Printer") ; Connect to the shared printer "\\192.168.1.1\HPDeskjetColor") _PrintMgr_AddWindowsPrinterConnection("\\192.168.1.1\HPDeskjetColor") ; List all installed printers #Include <Array.au3> $aPrinterList = _PrintMgr_EnumPrinter() _ArrayDisplay($aPrinterList) ; List all printers configuration #Include <Array.au3> $aPrinterConfig = _PrintMgr_EnumPrinterConfiguration() _ArrayDisplay($aPrinterConfig) ; List all installed printer drivers #Include <Array.au3> $aDriverList = _EnumPrinterDriver() _ArrayDisplay($aDriverList) ; Retrieve the printer configuration for the printer called "Lexmark T640" #Include <Array.au3> $aPrinterConfig = _PrintMgr_EnumPrinterConfiguration("Lexmark T640") _ArrayDisplay($aPrinterConfig) ; Add a local printer port (for a file output) _AddLocalPrinterPort("c:\temp\output.pcl") ; Remove the local port _RemoveLocalPrinterPort("c:\temp\output.pcl") Download link :  PrintMgr.au3
    • NiceBoy1234
      By NiceBoy1234
      How can I open a specific driver with Autoit, in my case I have an usb which has the driver letter of f.
    • ur
      By ur
      Is there any library or api in Autoit to check whether a particular driver is signed or not and check for the certificate validity of the driver/catalog file if it is signed.?
       
    • MyEarth
      By MyEarth
      Hi, maybe is a silly question but i don't have understood how to make a list of internal HDD and external HDD-Pen Drive using DriveGetDrive
      FIXED = Internal HDDs, right?
      REMOVABLE = External HDDs - PenDrive, right?
      How to get both in the same list? Thanks
×