You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
using System ;
using System.Diagnostics ;
using System.Threading ;
namespace RestartApp1
{
internal class Program
{
static void Main ( string [ ] args )
{
Thread . Sleep ( 5000 ) ;
// 设置要启动的应用程序名称和参数
string appName = args [ 0 ] ; //"XGLFinishPro.exe"; // 替换为你的目标控制台应用程序的名称
string appArguments = " " ; // 替换为你的应用程序需要的参数
Console . WriteLine ( appName ) ;
// 创建进程启动信息
ProcessStartInfo startInfo = new ProcessStartInfo
{
FileName = appName ,
Arguments = appArguments ,
RedirectStandardOutput = false , // 可以选择是否重定向标准输出
UseShellExecute = false , // 必须设置为false, 以便在控制台中启动应用程序
CreateNoWindow = false // 设置为true, 以便在后台启动应用程序
} ;
// 创建并启动进程
Process process = new Process
{
StartInfo = startInfo
} ;
process . Start ( ) ;
Console . ReadLine ( ) ;
Environment . Exit ( 0 ) ;
// 在这里添加你的应用程序的主要逻辑
}
}
}