I want to set a Process variable without using "Process.Start("procName")" inProcess myProcess = Process.Start("procName");
Any ideas on how to do that?
This will construct a new instance of the Process
class. But a more interesting question might be, why would you want to do this?
var proc = new Process();
You could use the .WaitForExit()
on the skyrim process. Here is an example that opens CMD.exe
and checks if notepad is open, if it is open it will wait for notepad to close before closing CMD.exe
Note that if notepad is not running the .CloseMainWindow()
fails because it comes to quick.
Process cmd = Process.Start("cmd.exe"); // get ENB process
Process[] p = Process.GetProcessesByName("notepad"); // Get "skyrim" here
if (p.Length > 0)
{
p[0].WaitForExit();
}
cmd.CloseMainWindow();
// or cmd.Close();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.