There are a couple of simple approaches to this. One is to do what you asked; to write the input text to a file named "textbox1.text" (really should be "textbox1.txt", though, since ".txt" is a common suffix for text files and ".text" isn't) and then let the batch script read it.
It's a whole lot easier to simply write the text to the standard output stream using Console.WriteLine() and let the batch file capture that and do what it wants with the text. Either way, you're going to need a character that's known not to ever be an input character.
I'll give the second approach as an example, but I won't use Forms or WPF. It's too hard to show what goes where. You seem to want a window with a text box, though, so I'll use the following "ConsoleApp1.cs" program and borrow the InputBox() function from Visual Basic (a neat console CS trick on its own!):
using System;
using Microsoft.VisualBasic;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
string answer = Interaction.InputBox("Tell me something");
Console.WriteLine(answer);
}
}
}
Compile that into a .exe file and copy it to the directory you're using for running .bat files. Now try the following within a batch file:
rem @echo off
for /F "delims=~" %%t in ('ConsoleApp1.exe') do set a=%%t
echo.%a%
That's the easy way to get one line of text from a CS program into the .bat file that called it. If you insist on having the CS program create a text file named "textbox1.text", go ahead. Look up how to use the StreamWriter class to do that. Then your .bat file will use a slightly different form of the FOR command:
for /F "delims=~" %%t in (textbox1.text) do set a=%%t
Either way, you need the character after delims= to be a delimiter character that will not by typed by the user. The FOR /F command always parses input lines into tokens separated by whatever delimiter characters you specify (or spaces by default). I use either ~ or ' as characters that don't normally show up in commands or file names.
Justaus3r made a valuable suggestion to use a redirected SET /P command. You can use that, with the above CS program to get the Console.WriteLine output into a variable with no delimiter worries:
ConsoleApp1.exe >textbox1.text
set /P a=<textbox1.text
That works. Piping output from ConsoleApp1 directly to SET ought to work too, but for some reason it doesn't. I've had a number of issues with old batch files that worked in Win7 that don't in Win10. This fails in both CMD and PowerShell, though, so there's something weirder going on that MS just isn't maintaining CMD any more.