Home > Net >  Asp.net winform control program to restart
Asp.net winform control program to restart

Time:09-22

As shown in figure, the first is winform program open, can display interface, the user name is Administrator;
The second is deployed in IIS WebTest open the asp.net project, process in, and the normal operation, but does not display interface, the user name is WebTest,
How can you use to deploy in IIS asp.net project WebTest click button to restart the winform procedure and display? Baidu all can not find appropriate method,
(don't deploy the IIS, use Visual Studio to open the asp.net project WebTest, click the button to restart winform procedure also can display interface, and the user name is Administrator, will not display after the deployment of IIS)


Code:
 
Protected void btnMin_Click (object sender, EventArgs e)
{
The Test ();
}

Private void Test ()
{
String strName="ByteTest";
Process [] proc=Process. GetProcessesByName (strName);
for (int i=0; i {
If (proc [I] ProcessName==strName)
{
[I]. Proc Kill ();
}
}
GC. Collect ();
ProcessStartInfo psInfo=new ProcessStartInfo ();
PsInfo. FileName=strName;
//do not display the form
PsInfo. CreateNoWindow=false;
//the superior directory file
PsInfo. WorkingDirectory=@ "D: \ Users \ xbingyov \ source \ repos \ ByteTest \ ByteTest \ bin \ Debug ";
Process the Process;
Try
{
The process=process. Start (psInfo);
}
The catch (System.Com ponentModel Win32Exception ex)
{
}
}
  • Related