@@ -19,6 +19,26 @@ int WINAPI WinMain(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPSTR /
19
19
std::wstring exeDir = exePath;
20
20
exeDir = exeDir.substr (0 , exeDir.find_last_of (L" \\ /" ));
21
21
22
+ // Get command line string and extract arguments
23
+ LPWSTR commandLine = GetCommandLineW ();
24
+ std::wstring args;
25
+ // If executable path is double quoted, skip the entire quoted section
26
+ if (commandLine[0 ] == L' "' ) {
27
+ LPWSTR closingQuote = wcschr (commandLine + 1 , L' "' );
28
+ if (closingQuote) {
29
+ args = closingQuote + 1 ;
30
+ }
31
+ // For non-quoted path, skip to character after first space if it exists
32
+ } else {
33
+ LPWSTR spacePos = wcschr (commandLine, L' ' );
34
+ if (spacePos) {
35
+ args = spacePos + 1 ;
36
+ }
37
+ }
38
+ // Strip leading whitespace
39
+ size_t args_start = args.find_first_not_of (L" " );
40
+ args = (args_start != std::wstring::npos) ? args.substr (args_start) : L" " ;
41
+
22
42
// Define the path to the "scripts" directory
23
43
std::wstring scriptsDir = exeDir + L" \\ scripts" ;
24
44
@@ -37,8 +57,13 @@ int WINAPI WinMain(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPSTR /
37
57
return 1 ;
38
58
}
39
59
40
- // Define the command to run
41
- std::wstring target = L" cmd.exe /c \" " LAUNCH_TARGET L" \" " ;
60
+ // Define the command to run and append arguments if present
61
+ std::wstring target;
62
+ if (!args.empty ()) {
63
+ target = L" cmd.exe /c \"\" " LAUNCH_TARGET L" \" " + args + L" \" " ;
64
+ } else {
65
+ target = L" cmd.exe /c \" " LAUNCH_TARGET L" \" " ;
66
+ }
42
67
43
68
// Configure the process startup info
44
69
STARTUPINFO si = { sizeof (si) };
0 commit comments