2

I want to pass a variable to a file with alternative data stream (ADS) in c#.

Batch example:

Put a flag:

echo true > c:\temp\a.7z:flag

Read the flag:

more < c:\temp\a.7z:flag

If I pass the batch command as an argument to cmd.exe (with Process object), I get the start message of cmd.exe:

Process myProcess = new Process();

myProcess.StartInfo.Arguments = args;
myProcess.StartInfo.FileName = exe;

Microsoft Windows [Version 6.1.7601] Copyright (c) 2009 Microsoft Corporation. Alle Rechte vorbehalten. C:\Users...\Visual Studio 2015\Projects\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug>

Is there any possibilty to use the batch command without using cmd.exe?

imsome1
  • 1,182
  • 4
  • 22
  • 37
Makuna
  • 558
  • 1
  • 6
  • 19
  • 1
    Show your code (i.e. what you're passing to StartInfo.FileName and StartInfo.Arguments. I suspect you're just passing the batch name to StartInfo.Arguments; you should be passing "/c myfile.bat". – Joe Feb 09 '17 at 08:46
  • 6
    You can deal with the [ADS directly](http://stackoverflow.com/questions/10477059/working-c-sharp-example-writing-reading-ntfs-alternate-data-stream-under-win7) instead of through CMD – Martheen Feb 09 '17 at 08:48
  • 2
    Martheen proposal is better. However, if you still want cmd.exe, you need add /c to arguments. Or you can set UseShellExecute to true and use bat file as FileName – vitalygolub Feb 09 '17 at 10:38

0 Answers0