How do I execute a batch file in an alternate data stream in Windows 7?

5

1

Normally, after creating an executable as an alternate data stream, for instance:

type exec_this.bat > C:\blank.txt:exe.bat

one could simply say

start C:\blank.txt:exe.bat

to run the executable. In Windows 7, all I seem to get is "Access is denied." or "The system cannot find the file $WHATEVER_THE_FILE_IS."

How can I execute this batch file?

Joseph Hansen

Posted 2011-05-16T20:40:30.117

Reputation: 3 578

This seems like a bad idea. What's your use case? – uSlackr – 2011-05-16T21:48:25.000

Answers

5

Windows 7 silently removed the ability to execute anything from an ADS. However, from the DOS command line, there are other options. For a batch file, you can execute line by line:

for /f "usebackq delims=φ" %i in (blank.txt:exe.bat) do %i

(Keep in mind, this does not actually execute the batch file into its own process, it simply reads and executes each line from the file. The φ symbol is typed with alt code number 2541. You want the delimiter to be a character you wouldn't ever use in the code.)

Joseph Hansen

Posted 2011-05-16T20:40:30.117

Reputation: 3 578