我看到Windows将文件上的属性显示为ALO。 我需要一个Windows(不是Powershell命令)来列出文件中的属性。
但是当我使用attrib命令时。它仅将set属性显示为A LO属性丢失。
操作系统:Windows 7。
https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/attrib
答案 0 :(得分:1)
滚动自己的
ConsoleAttr.vb
imports System.Runtime.InteropServices
Public Module MyApplication
Public Declare Unicode Function GetFileAttributesW Lib "Kernel32" (ByVal Path As String) As Integer
Public Const FILE_ATTRIBUTE_ARCHIVE = 32
Public Const FILE_ATTRIBUTE_COMPRESSED = 2048
Public Const FILE_ATTRIBUTE_DEVICE = 64
Public Const FILE_ATTRIBUTE_DIRECTORY = 16
Public Const FILE_ATTRIBUTE_ENCRYPTED = 16384
Public Const FILE_ATTRIBUTE_HIDDEN = 2
Public Const FILE_ATTRIBUTE_INTEGRITY_STREAM = 32768
Public Const FILE_ATTRIBUTE_NORMAL = 128
Public Const FILE_ATTRIBUTE_NOT_CONTENT_INDEXED = 8192
Public Const FILE_ATTRIBUTE_NO_SCRUB_DATA = 131072
Public Const FILE_ATTRIBUTE_OFFLINE = 4096
Public Const FILE_ATTRIBUTE_READONLY = 1
Public Const FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS = 4194304
Public Const FILE_ATTRIBUTE_RECALL_ON_OPEN = 262144
Public Const FILE_ATTRIBUTE_REPARSE_POINT = 1024
Public Const FILE_ATTRIBUTE_SPARSE_FILE = 512
Public Const FILE_ATTRIBUTE_SYSTEM = 4
Public Const FILE_ATTRIBUTE_TEMPORARY = 256
Public Const FILE_ATTRIBUTE_VIRTUAL = 65536
Public Sub Main ()
Dim Ret as Integer
Dim OutPut As String
Output = Command() & " "
Ret = GetFileAttributesW(Command())
If Ret = 0 Then
Console.writeline("Error " & err.lastdllerror)
Else
If (Ret And FILE_ATTRIBUTE_ARCHIVE) = FILE_ATTRIBUTE_ARCHIVE Then Output = OutPut & "Archive "
If (Ret And FILE_ATTRIBUTE_COMPRESSED) = FILE_ATTRIBUTE_COMPRESSED Then Output = OutPut & "Compressed "
If (Ret And FILE_ATTRIBUTE_DEVICE) = FILE_ATTRIBUTE_DEVICE Then Output = OutPut & "Device "
If (Ret And FILE_ATTRIBUTE_DIRECTORY) = FILE_ATTRIBUTE_DIRECTORY Then Output = OutPut & "Directory "
If (Ret And FILE_ATTRIBUTE_ENCRYPTED) = FILE_ATTRIBUTE_ENCRYPTED Then Output = OutPut & "Encrypted "
If (Ret And FILE_ATTRIBUTE_HIDDEN) = FILE_ATTRIBUTE_HIDDEN Then Output = OutPut & "Hidden "
If (Ret And FILE_ATTRIBUTE_INTEGRITY_STREAM) = FILE_ATTRIBUTE_INTEGRITY_STREAM Then Output = OutPut & "Integrity_Stream "
If (Ret And FILE_ATTRIBUTE_NORMAL) = FILE_ATTRIBUTE_NORMAL Then Output = OutPut & "Normal "
If (Ret And FILE_ATTRIBUTE_NOT_CONTENT_INDEXED) = FILE_ATTRIBUTE_NOT_CONTENT_INDEXED Then Output = OutPut & "Not_Content_Indexed "
If (Ret And FILE_ATTRIBUTE_NO_SCRUB_DATA) = FILE_ATTRIBUTE_NO_SCRUB_DATA Then Output = OutPut & "No_Scrub_Data "
If (Ret And FILE_ATTRIBUTE_READONLY) = FILE_ATTRIBUTE_READONLY Then Output = OutPut & "ReadOnly "
If (Ret And FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS) = FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS Then Output = OutPut & "Recall_On_Data_Access "
If (Ret And FILE_ATTRIBUTE_RECALL_ON_OPEN) = FILE_ATTRIBUTE_RECALL_ON_OPEN Then Output = OutPut & "Recall_On_Open "
If (Ret And FILE_ATTRIBUTE_REPARSE_POINT) = FILE_ATTRIBUTE_REPARSE_POINT Then Output = OutPut & "Reparse "
If (Ret And FILE_ATTRIBUTE_SPARSE_FILE) = FILE_ATTRIBUTE_SPARSE_FILE Then Output = OutPut & "Sparse "
If (Ret And FILE_ATTRIBUTE_SYSTEM) = FILE_ATTRIBUTE_SYSTEM Then Output = OutPut & "System "
If (Ret And FILE_ATTRIBUTE_TEMPORARY) = FILE_ATTRIBUTE_TEMPORARY Then Output = OutPut & "Temporary "
If (Ret And FILE_ATTRIBUTE_VIRTUAL) = FILE_ATTRIBUTE_VIRTUAL Then Output = OutPut & "Virtual "
End If
Console.writeline(OutPut)
End Sub
End Module
要编译
ConsoleAttr.bat
C:\Windows\Microsoft.NET\Framework\v4.0.30319\vbc "%~dp0\ConsoleAttr.vb" /out:"%~dp0\ConsoleAttr.exe" /target:exe
一些例子
C:\Windows\system32>"C:\Users\User\Desktop\ConsoleAttr.exe" \\?\c:\bootnxt
\\?\c:\bootnxt Archive Hidden System
C:\Windows\system32>"C:\Users\User\Desktop\ConsoleAttr.exe" \\?\c:\windows\winsxs
\\?\c:\windows\winsxs Directory
C:\Windows\system32>"C:\Users\User\Desktop\ConsoleAttr.exe" c:\windows\win.ini
c:\windows\win.ini Archive
要做多个文件放入for循环中。
For %A in ("c:\windows\*.exe") Do @"C:\Users\User\Desktop\ConsoleAttr.exe" %A
c:\windows\bfsvc.exe Archive
c:\windows\explorer.exe Archive
c:\windows\extrac32.exe Archive
c:\windows\HelpPane.exe Archive
c:\windows\hh.exe Archive
c:\windows\notepad.exe Archive
c:\windows\regedit.exe Archive
c:\windows\REGTLIB.EXE Archive
或目录
For /d %A in ("c:\windows\system32\*") Do @"C:\Users\User\Desktop\ConsoleAttr.exe" %A