Имя пользователя:
Пароль:  
Помощь | Регистрация | Забыли пароль?  

Показать сообщение отдельно

Ветеран


Сообщения: 27449
Благодарности: 8087

Профиль | Отправить PM | Цитировать


Цитата daniil_im:
Подскажите начинающему, как должен выглядеть правильный код этого задания »
Примерно так:
Скрытый текст
Код: Выделить весь код
Option Explicit

Dim strDestFile

Dim objTS
Dim objFolder


With WScript.CreateObject("Scripting.FileSystemObject")
	strDestFile = .BuildPath(WScript.CreateObject("WScript.Shell").SpecialFolders.Item("MyDocuments"), "текстовый файл.txt")
	
	If .DriveExists("C:") Then
		Set objTS = .CreateTextFile(strDestFile, True, True)
		
		For Each objFolder In .GetFolder("C:\").SubFolders
			objTS.WriteLine ComposeAttributesString(objFolder.Attributes) & vbTab & objFolder.Name
		Next
		
		objTS.Close
		Set objTS = Nothing
	Else
		WScript.Echo "Drive C: not exists."
		WScript.Quit 1
	End If
End With

WScript.Quit 0

Function ComposeAttributesString(intAttributes)
	Dim strResult
	
	strResult = ""
	
	If intAttributes And 16   Then strResult = strResult & "D" Else strResult = strResult & " "
	If intAttributes And 2048 Then strResult = strResult & "C" Else strResult = strResult & " "
	If intAttributes And 1024 Then strResult = strResult & "L" Else strResult = strResult & " "
	If intAttributes And 32   Then strResult = strResult & "A" Else strResult = strResult & " "
	If intAttributes And 4    Then strResult = strResult & "S" Else strResult = strResult & " "
	If intAttributes And 2    Then strResult = strResult & "H" Else strResult = strResult & " "
	If intAttributes And 1    Then strResult = strResult & "R" Else strResult = strResult & " "
	
	ComposeAttributesString = strResult
End Function
Это сообщение посчитали полезным следующие участники:

Отправлено: 19:08, 19-09-2017 | #2