Option Explicit Dim wshShell, wshFSO, wshFolder, strMSG, FileCount, File, wshFileOut, YesNoResponse Set wshShell = WScript.CreateObject("WScript.Shell") Set wshFSO = WScript.CreateObject("Scripting.FileSystemObject") Set wshFolder = wshFSO.GetFolder(wshShell.CurrentDirectory) strMSG = "В папке [" & wshShell.CurrentDirectory & "] находятся следующие файлы:" & vbCrLf & vbCrLf For Each File In wshFolder.Files If Not File.Name = Wscript.ScriptName Then strMSG = strMSG & File.Name & vbCrLf FileCount = FileCount + 1 End If Next strMSG = strMSG & vbCrLf & "Количество файлов: " & FileCount If wshFSO.FileExists("Dosieroj.txt") = True Then YesNoResponse = MsgBox("Файл Dosieroj.txt уже существует. Заменить его на новый?", vbYesNo + vbExclamation, "Читай@Отвечай") If YesNoResponse = vbNo Then WScript.Quit End if Set wshFileOut = wshFSO.CreateTextFile("Dosieroj.txt", True) wshFileOut.Write strMSG MsgBox strMSG, vbInformation, "Список файлов"