c# - Restart an application by itself -


i want build application function restart itself. found on codeproject

processstartinfo info=new processstartinfo(); info.arguments="/c choice /c y /n /d y /t 3 & del "+                application.executablepath; info.windowstyle=processwindowstyle.hidden; info.createnowindow=true; info.filename="cmd.exe"; process.start(info);  application.exit(); 

this not work @ all... , other problem is, how start again this? maybe there arguments start applications.

edit:

http://www.codeproject.com/script/articles/articleversion.aspx?aid=31454&av=58703 

i use similar code code tried when restarting apps. send timed cmd command restart app me this:

processstartinfo info = new processstartinfo(); info.arguments = "/c ping 127.0.0.1 -n 2 && \"" + application.executablepath + "\""; info.windowstyle = processwindowstyle.hidden; info.createnowindow = true; info.filename = "cmd.exe"; process.start(info); application.exit();  

the command sent os, ping pauses script 2-3 seconds, time application has exited application.exit(), next command after ping starts again.

note: \" puts quotes around path, incase has spaces, cmd can't process without quotes.

hope helps!


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -