-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.cpp
More file actions
26 lines (20 loc) · 735 Bytes
/
start.cpp
File metadata and controls
26 lines (20 loc) · 735 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <windows.h>
#include <iostream>
int main() {
// Path to the shell executable
std::string shellPath = "shell.exe";
// Command to open a new cmd window and run the shell
std::string command = "cmd /c start cmd /c \"" + shellPath + "\"";
// Set up process startup info
STARTUPINFO si = { sizeof(STARTUPINFO) };
PROCESS_INFORMATION pi;
// Create a new process (new terminal window)
if (!CreateProcess(nullptr, const_cast<char*>(command.c_str()), nullptr, nullptr, FALSE, 0, nullptr, nullptr, &si, &pi)) {
std::cerr << "Failed to open new terminal.\n";
return 1;
}
// Close process handles
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
return 0;
}