09-17-2022, 11:43 AM
(This post was last modified: 09-17-2022, 11:43 AM by Kernelpanic.)
This is probably easier to do with VBScript (Windows Scripting Host).
The program example should show that you can also delete under Windows without asking. I have now changed it so that a folder is created via the query, which is then automatically after 5 seconds deleted again. That could certainly be easily converted to create any folder. In the end it's more of a gimmick. But one can learn from it.
In my example, the folder "Beispiel" is created in H:\Ablage\Beispiel. Adapt it to your own system when trying it out. Name: XYZ.vbs
The program example should show that you can also delete under Windows without asking. I have now changed it so that a folder is created via the query, which is then automatically after 5 seconds deleted again. That could certainly be easily converted to create any folder. In the end it's more of a gimmick. But one can learn from it.
In my example, the folder "Beispiel" is created in H:\Ablage\Beispiel. Adapt it to your own system when trying it out. Name: XYZ.vbs
Code: (Select All)
'Windows Scripting Host Beispiel, 15. April 2019/14. Sept. 2022
'Erstellt einen Ordner und löscht ihn nach 5 sek. ohne Abfrage
'Variablendeklaration erzwingen
Option Explicit
Dim Pfad, NeuerPfad, OrdnerAnzeigen
Dim fso, fo
NeuerPfad = Inputbox("Neuen Ordner mit Pfad angeben: ")
'Hier: H:\Ablage\Beispiel
Pfad = NeuerPfad
'FileSystemObject erzeugen fuer Zugriff
Set fso = WScript.CreateObject("Scripting.FileSystemObject")
'Pruefen ob Ordner schon existiert
If (Not fso.FolderExists(Pfad)) Then
'Ordner erstellen
Set fo = fso.CreateFolder(Pfad)
End If
'Neu erstellten Ordner anzeigen
OrdnerAnzeigen = fso.GetParentFolderName(Pfad)
Set fo = fso.GetFolder(OrdnerAnzeigen)
'5 Sekunden warten
WScript.Sleep 5000
'Ordner ohne Nachfrage loeschen
fso.DeleteFolder(Pfad)
WScript.Quit
'***Ende