#include <windows.h>
//隐藏控制台界面
#pragma comment(linker,"/subsystem:\"windows\" /entry:\"mainCRTStartup\"")
void RunProcess(int nDelay,char* szCmd)
{
STARTUPINFO si = {sizeof(si)};
PROCESS_INFORMATION pi;
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_SHOWNORMAL;
si.lpDesktop = "winsta0\\default";
Sleep(nDelay*1000);
CreateProcess(NULL,(char*)(szCmd),NULL,NULL,FALSE,0,NULL,NULL,&si,&pi);
if (pi.hProcess != NULL)
CloseHandle(pi.hProcess);
if (pi.hThread != NULL)
CloseHandle(pi.hThread);
}
int _tmain(int argc, _TCHAR* argv[])
{
if (argc == 2)
{
RunProcess(5,argv[1]);
}
//RunProcess(5,"c:\\windows\\system32\\calc.exe");
return 0;
}