这是我构建 .bat 文件并运行它的代码。
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");
但是,我的访问被拒绝,我必须以管理员身份运行它,我该怎么做?