Чтение и изменение атрибутов файла

Чтение атрибутов:

Option Explicit
On Error Resume Next  
Dim objFSO
Dim objFile
Dim Target

Target = "C:\boot.ini"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile(Target)

WScript.Echo "The file is: " & target
WScript.Echo "bitmap number is: " & (objFile.attributes)

Select Case objFile.Attributes
	Case 0
		WScript.Echo "No Attributes Set"
	Case 1
		WScript.Echo "Read-Only"
	Case 2
		WScript.Echo "Hidden File"
	Case 3
		WScript.Echo "Read-Only, Hidden File"
	Case 4
		WScript.Echo "System File"
	Case 6
		WScript.Echo "Hidden, System File"
	Case 7
		WScript.Echo "Read-Only, Hidden, System File"
	Case 32
		WScript.Echo "Archive bit Set"
	Case 64
		WScript.Echo "Link or Shortcut"
	Case 2048
		WScript.Echo "Compressed file"
End Select

Изменение аттрибутов:

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile("C:\scripts\test.txt")

wscript.echo "Beginning attribute is " & objfile.attributes 

If (objFile.attributes AND 1) = 0 Then
	objFile.Attributes = (objFile.Attributes Xor 1)
Else
	WScript.Echo("File attributes are unchanged: ")
End If

WScript.Echo "End File Attribute is: " & objFile.Attributes
Интересное на сайте: 
0
Голосов пока нет

Оставить комментарий