调用计算器:System.Diagnostics.Process.Start("calc.exe");
调用word程序:System.Diagnostics.Process.Start("WINWORD.exe");
调用计事本:System.Diagnostics.Process.Start("notepad.exe");
调用Excel: System.Diagnostics.Process.Start("excel.exe");
调用SQL2005:System.Diagnostics.Process.start("SqlWb.exe");
---------------------------------------------------------------------------------
将你的net use \\172.16.17.1 /user:username password写到bat文件中,然后运行下面代码就可以了。
程序控制参数方法:
lovevsnet(编程一把手)提到:
System.Diagnostics.ProcessStartInfo psi =
//prompt
psi.FileName = @"C:\WINDOWS\system32\cmd.exe"; // Path for the cmd prompt
psi.Arguments
psi.WindowStyle=System.Diagnostics.ProcessWindowStyle.Hidden;
System.Diagnostics.Process.Start(psi);
就是用进程启动cmd.exe
使用Process类运行ShellExecute的一个问题(点击查看引用)
只有在STA线程上ShellExecute 才能确保工作无误。在Process的实现中,并没有考虑到这个问题,所以使用Process类运行ShellExecute可能会出错。如果你不能保证调用Process.Start的线程的ApartmentState,可以使用如下的代码来避免这个问题:
using System;
using System.Threading;
public class Foo {
}
-----------------------------------------------------------------------
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo.FileName= "notepad.exe";
proc.Start();
proc.WaitForExit();
来源:(http://blog.sina.com.cn/s/blog_62822a7f0100fk32.html) - C#调用Windows应用程序 System.Diagnostics.Process_thinker_新浪博客

浙公网安备 33010602011771号