Haette mal eine Frage.
Auf meinem Fileserver sind einige Verzeichnisse schreibgeschützt.
Diese Verzeichnisse will ich "entlarven".
Folgendes kleines Programm geht den Filebaum durch und schreibt in jedes Verzeichniss eine Datei.
Bei Schreibschutz wird der Pfad aufgelistet.
Das funktioniert praechtig.
Gibt es aber eine Lösung ohne die Testdatei zu erzeugen?
Bin mir sicher die Lösung geht auch sauber.
Vielen Dank schonmal.
GreyEnt
Hier mein Tool in 5.62.
Code: Alles auswählen
;
; ------------------------------------------------------------
;
; RW-Check
; Dieses Programm checkt ein Verzeichnisbaum auf schreibschutz.
; 22.07.2018 GreyEnt
; Geschrieben für PureBasic 5.62(x64) Windows
;
;
; ------------------------------------------------------------
;
If OpenWindow(0, 100, 100, 800, 600, "Read - Write Check", #PB_Window_MinimizeGadget)
pfad = ListViewGadget(#PB_Any, 10, 10, 150, 100)
dir = ButtonGadget (#PB_Any , 170, 10, 70 , 24, "Directory")
scan = ButtonGadget (#PB_Any , 250, 10, 60 , 24, "scan...")
clipboard = ButtonGadget (#PB_Any , 320, 10, 110 , 24, "Create Report File")
DisableGadget(clipboard, 1)
ListViewGadget(2, 10, 120, WindowWidth(0)-20, 460)
TextGadget(3,170,60,60,24,"Progress:")
TextGadget(4,230,60,120,24,"Select Directory")
TextGadget(5,170,90,600,24,"Current...")
countdir.l=0
NewList dirlist.s()
Repeat
EventID = WaitWindowEvent()
If EventID = #PB_Event_Gadget
;{ Verzeichnis auswählen
If EventGadget() = dir ; Verzeichnis auswählen
Path$ =""
Path$ = PathRequester("Bitte wählen Sie einen Pfad aus", "c:\")
If Path$<>""
ClearGadgetItems(pfad)
AddGadgetItem(pfad, -1, Path$)
countdir=0
SetGadgetText(5,"Current")
SetGadgetText(4,"Select Scan...")
EndIf
EndIf
;}
;{ scan
If EventGadget() = scan ; Read
ClearList(dirlist())
For pathindex = 0 To CountGadgetItems(pfad)
AddElement(dirlist())
countdir=0
SetGadgetText(5,"Current")
dirlist() = GetGadgetItemText(pfad, pathindex)
praefix.s=dirlist()
Next
StartTime = ElapsedMilliseconds()
While ListSize(dirlist()) > 0
FirstElement(dirlist())
If ExamineDirectory(0, dirlist() , "*.*")
praefix=dirlist()
While NextDirectoryEntry(0)
FileName$ = DirectoryEntryName(0)
If DirectoryEntryType(0) = #PB_DirectoryEntry_Directory
If FileName$<>"." And FileName$<>".."
AddElement(dirlist())
dirlist() = praefix + FileName$ + "\"
countdir+1
viewdir.s = dirlist()
If CreateFile(0, dirlist()+"loeschmich.txt")
Else
AddGadgetItem(2, -1, dirlist()+" read only")
EndIf
;CloseFile(0)
;Debug dirlist()
EndIf
Else
EndIf
Delay(1)
ElapsedTime = ElapsedMilliseconds()-StartTime
If ElapsedTime > 100
SetGadgetText(4, Str(countdir)+ " Directorys scanned")
SetGadgetText(5, viewdir)
StartTime = ElapsedMilliseconds()
EndIf
Wend
FinishDirectory(0)
SetGadgetText(4,"Finish")
EndIf ;ExamineDirectory
FirstElement(dirlist())
DeleteElement(dirlist())
Wend ;ListSize(dirlist()) > 0
DisableGadget(clipboard, 0)
EndIf ;EventGadget() = scan ; Read
;}
;{ Clipboard
If EventGadget() = clipboard ; Ergebnis kopieren
CreateFile(0, "Report.txt")
WriteStringN(0,"CPU Name: "+CPUName())
WriteStringN(0,"Computer Name: "+ComputerName())
WriteStringN(0,"OS Version "+Str(OSVersion()))
WriteStringN(0,"User Name: "+UserName())
InitNetwork()
WriteStringN(0,"Host Name: "+Hostname() )
Date$ = FormatDate("%yyyy/%mm/%dd", Date())
Time$ = FormatDate("%hh:%ii:%ss", Date())
WriteStringN(0,"Date: "+Date$+" Time: "+Time$)
For Eintrag= 0 To CountGadgetItems(2)
WriteStringN(0, GetGadgetItemText(2, Eintrag))
Next
CloseFile(0)
DisableGadget(clipboard, 1)
EndIf
;}
EndIf ;EventID = #PB_Event_Gadget
Until EventID = #PB_Event_CloseWindow
EndIf ;OpenWindow(0, 100, 100, 800, 600, "Read - Write Check", #PB_Window_MinimizeGadget)
End
Code-Tags hinzugefügt
28.07.2018
RSBasic