(12-22-2023, 07:05 PM)Kernelpanic Wrote: An example script that basically works, but the "opt" folder cannot be deleted. Even with >runas /user:Administrator ".vbs"< the folder cannot be deleted.
Maybe someone has a solution. Ultimately it's more complicated than deleting the folders by hand.
Code: (Select All)
'WSHost Ordner löschen, 22. Dez. 2023
'Variablendeklaration erzwingen
Option Explicit
Dim Pfad, OrdnerInhaltAnzeigen
Dim fso, fi, fo
Const ordner1 = "D:\QuickBasic64\qb64pe-3-8-0\internal\c\c_compiler\licenses"
Const ordner2 = "D:\QuickBasic64\qb64pe-3-8-0\internal\c\c_compiler\opt"
Const ordner3 = "D:\QuickBasic64\qb64pe-3-8-0\internal\c\c_compiler\share"
'Zum Ordner
Pfad = "D:\QuickBasic64\qb64pe-3-8-0\internal\c\c_compiler"
'FileSystemObject erzeugen fuer Zugriff
Set fso = WScript.CreateObject("Scripting.FileSystemObject")
If (Not fso.FolderExists(ordner1)) Then
WScript.Echo "Datei " & ordner1 & " existiert nicht!"
Else
fso.deleteFolder(ordner1)
WScript.Echo "Ordner " & ordner1 & " geloescht."
End if
If (Not fso.FolderExists(ordner3)) Then
WScript.Echo "Datei " & ordner3 & " existiert nicht!"
Else
fso.deleteFolder(ordner3)
WScript.Echo "Ordner " & ordner3 & " geloescht."
End if
If (Not fso.FolderExists(ordner2)) Then
WScript.Echo "Datei " & ordner2 & " existiert nicht!"
Else
fso.deleteFolder(ordner2)
WScript.Echo "Ordner " & ordner2 & " geloescht."
End if
'Beenden'
WScript.Quit
'***Ende
Many of the TCL8.6 support files in OPT are set as Read-Only, so a simple fso.deleteFolder will not work.
fso.deleteFolder has an optional "Force" flag you must use to force deletion of Read-Only files.
You can do it this way:
Const Force = True
fso.deleteFolder ordner2, Force
but
fso.deleteFolder ordner2, True
works as well.
That is why my batch file uses "RD /Q /S". It deletes a folder and all contents regardless of attribute bits.