Search code examples
batch-fileads

Create an alternate data stream mid batch file run


I'm trying to create a file in a batch scrript, and also create a ADS (alternate data stream) to the same file, the script looks like this:

@echo off


echo. 2>notSecret.txt

echo. 2>notSecret.txt:secret

@echo this is not a secret file... or is it :O > notSecret.txt

@echo this is the secret part! > notSecret.txt:secret
@echo great work >>notSecret.txt:secret
@echo you found it >> notSecret.txt:secret

the file is created, but it's ADS isn't.


Solution

  • We need to add a .txt file extension to the ADS echo

    @echo off
    
    echo this is not a secret file... or is it :O > notSecret.txt
    
    echo this is the secret part! > notSecret.txt:Secret.txt