以管理员权限运行 cmd 命令 [英] Running cmd commands with Administrator rights
本文介绍了以管理员权限运行 cmd 命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在 Windows 窗体的幕后运行命令 **cd..**
?(即用户看不到)
How can I run the command **cd..**
behind the scenes of a Windows Form? (i.e. the user cannot see it)
谢谢.
推荐答案
请参阅 System.Diagnostics.Process http://msdn.microsoft.com/en-us/library/system.diagnostics.process.aspx
See System.Diagnostics.Process http://msdn.microsoft.com/en-us/library/system.diagnostics.process.aspx
对于同样的问题也有这样的答案: https://stackoverflow.com/a/1469790/25882
示例:
System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.FileName = "cmd.exe";
startInfo.Arguments = "/C copy /b Image1.jpg + Archive.rar Image2.jpg";
startInfo.Verb = "runas";
process.StartInfo = startInfo;
process.Start();
这篇关于以管理员权限运行 cmd 命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文