我想提前道歉,因为这个问题可能已经在其他地方得到了回答(找不到具体答案)。我进行了广泛的搜索,这让我越来越困惑。在这一点上,我想我可以轻松快速地回答我的具体问题/困境。
我有一个 C# Windows 窗体应用程序。我正在使用文本框和按钮进行测试。我希望用户在文本框中输入一个 3 位数字,然后单击按钮将 3 位用户输入保存为字符串值,然后启动一个预先确定的 .BAT 文件。然后我想让我的 .BAT 文件执行输入 GOTO字符串。这是我到目前为止所拥有的:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace ComboBoxAndButton
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.textBox1.KeyPress += new KeyPressEventHandler(textBox1_KeyPress);
}
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
e.Handled = !char.IsDigit(e.KeyChar);
}
public string opconumber;
private void textBox1_TextChanged(object sender, EventArgs e)
{
opconumber = textBox1.Text;
}
private void button1_Click(object sender, EventArgs e)
{
Start();
}
private void Start()
{
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo.FileName = @"C:\mybat.bat";
//I am guessing that i need my string inserted somewhere in here.
proc.StartInfo.RedirectStandardError = false;
proc.StartInfo.RedirectStandardOutput = false;
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
proc.EnableRaisingEvents = true;
proc.Start();
proc.WaitForExit();
this.Close();
}
}
}
我遇到的另一件事是让退格键工作。我尝试了几个不同的片段,但无法正确处理。任何指示或批评都是公开接受的。提前致谢!
编辑:
好的。我有一个批处理文件,我想跳到一个特定的标签。我希望我保存的字符串变量充当 bat 文件中执行的决定因素。这是一个例子:
@echo off
:111 ECHO Argument 111
goto end
:112 ECHO Argument 112
goto end
:end
pause
如何在启动蝙蝠时使用字符串“112”让蝙蝠从 :112 开始?