3 replies
by cykeong Accepted solution
by jcooper987 Accepted solution
using System;
using System.Collections.Generic;
using System.Text;
namespace test
{
class Program
{
static void Main(string[] args)
{
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.EnableRaisingEvents = false;
proc.StartInfo.FileName = @"C:\test22.bat";
proc.StartInfo.Arguments = "";
proc.StartInfo.CreateNoWindow = false;
proc.Start();
proc.WaitForExit();
}
}
}
by andrei.ciprian Accepted solution
You could use any of these calls:
1. ShellExecute
2. ShellExecuteEx
3. CreateProcess
Only ShellExecute does not return a process handle.
Here's an exemple with ShellExecuteEx:
SHELLEXECUTEINFO shexinf;
shexinf.cbSize = sizeof (SHELLEXECUTEINFO);
shexinf.hwnd = 0;
shexinf.lpVerb = _T("open");
shexinf.lpFile = GetScriptPath();
shexinf.lpParameters = GetScriptAdditionalArguments();
shexinf.lpDirectory = 0;
shexinf.nShow = SW_HIDE;
shexinf.fMask = SEE_MASK_NOCLOSEPROCESS;
shexinf.hInstApp = 0;
if (! ShellExecuteEx (&shexinf))
{
// handle error
// use shexinf.hInstApp
}
if (shexinf.hProcess)
WaitForSingleObject (shexinf.hProcess, INFINITE);
This discussion is closed to new replies.
Trending Software posts
Sort by Trending