出自ProgWiki
使用Win32 API
WinExec
//定義
[DllImport("kernel32.dll")]
static extern uint WinExec(string lpCmdLine, uint uCmdShow);
//使用
uint SW_HIDE = 0;
uint SW_SHOW = 5;
string strFilename ="notepad.exe";
WinExec(strFilename, SW_SHOW);
CreateProcess
ShellExecute
-
ShellExecuteEx
使用ActiveX
Shell.Application
- ShellExecute Method
- 這個ActiveX因為常用於病毒或木馬的入侵管道(以VBScript或JavaScript去Call外部的exe檔),所以常被安全性設定或掃毒軟體所封鎖。
<script language="JScript">
function fnShellExecuteJ()
{
var objShell = new ActiveXObject("Shell.Application");
objShell.ShellExecute("notepad.exe", "", "", "open", 1);
}
</script>
使用.NetFramework
System.Diagnostics.Process.Start
-
- 範例:
System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo();
psi.FileName = "notepad.exe";
psi.Arguments = "c:\\1.txt";
System.Diagnostics.Process.Start(psi);