Search code examples
vbscriptstreamntfs

Accessing NTFS Alternate Data Streams with VBScript


I am writing a VBScript that I would like to be able to alter the Zone Identifier, and add Extended Attributes to various files with. Is this possible without the use addons, or something like the below?

objShell.run("type %windir%\notepad.exe > %windir%\calc.exe:notepad.exe")

Solution

  • You can handle ADS like other files:

    Set fso = CreateObject("Scripting.FileSystemObject")
    
    Set f = fso.CreateTextFile("file.exe:Zone.Identifier")
    f.WriteLine "[ZoneTransfer]" & vbNewLine & "ZoneId=3"
    f.Close
    
    Set f = fso.OpenTextFile("file.exe:Zone.Identifier", 1)
    WScript.Echo f.ReadAll
    f.Close