This is my code to build up a .bat file and run it.
StringBuilder Batch = new StringBuilder();
Batch.AppendLine("@echo off");
Batch.AppendLine("taskkill /IM " + Process.GetCurrentProcess().ProcessName + ".exe /F");
Batch.AppendLine("ping localhost > nul");
Batch.AppendLine("del /f " + (char)34 + Application.ExecutablePath + (char)34);
Batch.AppendLine("ren " + (char)34 + Application.StartupPath + @"\update.exe" + (char)34 + " " + Process.GetCurrentProcess().ProcessName);
Batch.AppendLine((char)34 + Application.ExecutablePath + (char)34);
Batch.AppendLine("del %0");
File.WriteAllText(Application.StartupPath + @"\update.bat", Batch.ToString(), Encoding.Default);
Process.Start(Application.StartupPath + @"\update.bat");
However, I get access is denied, I have to run it as a admin, how can I do it?