Trying to launch a file located in System32 as administrator but it keeps telling me it doesn't exist.
Error: System can't find specified file
Build Target Platform is: x86.
Current OS: Windows 8.1 x64. I'd rather not have 2 different .exes for a 32 and 64 bit os.
p.StartInfo.Verb = "runas";
p.StartInfo.FileName =
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System),"Defrag.exe");
//above points to c:windowssystem32defrag.exe
p.StartInfo.Arguments = @"c: /A";
p.Start();
p.WaitForExit();
I have also tried the following with no luck
p.StartInfo.FileName =
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), "sysnative", "Defrag.exe");
Update
Switched the app from x86 to Any CPU corrected the issue
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…