Guest User

Untitled

a guest
Apr 23rd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. string shell(string program, string command, int rm=-1)
  2. {
  3. LPTSTR prog, windir;
  4. GetWindowsDirectory(windir, MAX_PATH);
  5. if(program.find(":")==string::npos)
  6. {
  7. program = string(windir)+"\\System32\\"+program;
  8. }
  9. prog = (LPTSTR) program.c_str();
  10. STARTUPINFO si;
  11. PROCESS_INFORMATION pi;
  12. SECURITY_ATTRIBUTES sec;
  13.  
  14.  
  15. ZeroMemory( &si, sizeof(si));
  16. si.cb = sizeof(si);
  17. ZeroMemory( &pi, sizeof(pi));
  18. ZeroMemory( &sec, sizeof(sec));
  19.  
  20. sec.nLength = sizeof(sec);
  21. sec.lpSecurityDescriptor = NULL;
  22. sec.bInheritHandle = FALSE;
  23.  
  24. MessageBox(NULL, (char*) windir, program.c_str(), 0);
  25. if(CreateProcess((LPCTSTR) prog , "/c dir", NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi)==0)
  26. {
  27. char* serr;
  28. sprintf(serr, "CreateProcess failed (%d)\n", GetLastError());
  29. MessageBox(NULL, "testicles", "error", MB_ICONERROR);
  30. return string(serr);
  31. }
  32. MessageBox(NULL, "testarin", "error", MB_ICONERROR);
  33.  
  34. return "";
  35. }
Add Comment
Please, Sign In to add comment