3131#include " Workspace.h"
3232#include " QuickLoader.h"
3333#include " ArgumentsHandler.h"
34+ #include " SaUtils.h"
35+
3436#include " rapidassist/testing.h"
3537#include " rapidassist/filesystem_utf8.h"
3638#include " rapidassist/user.h"
3941#include " rapidassist/process.h"
4042#include " rapidassist/cli.h"
4143#include " rapidassist/random.h"
44+ #include " rapidassist/errors.h"
4245
4346#ifndef WIN32_LEAN_AND_MEAN
4447#define WIN32_LEAN_AND_MEAN 1
@@ -212,6 +215,104 @@ namespace shellanything
212215 return false ;
213216 }
214217
218+ void KillShellAnythingArgumentsDebuggerProcess ()
219+ {
220+ printf (" Killing all arguments.debugger.window.exe processes...\n " );
221+
222+ if (ra::environment::IsConfigurationDebug ())
223+ system (" cmd.exe /c taskkill /IM arguments.debugger.window-d.exe >NUL 2>NUL" );
224+ else
225+ system (" cmd.exe /c taskkill /IM arguments.debugger.window.exe >NUL 2>NUL" );
226+
227+ ra::timing::Millisleep (1000 );
228+
229+ printf (" killed.\n " );
230+ }
231+
232+ bool StartShellAnythingArgumentsDebuggerProcess (ra::process::processid_t & pId)
233+ {
234+ printf (" Starting arguments.debugger.window.exe...\n " );
235+
236+ // Build path of arguments.debugger.window.exe
237+ std::string current_process_dir = ra::process::GetCurrentProcessDir ();
238+ std::string process_path;
239+ if (ra::environment::IsConfigurationDebug ())
240+ process_path = current_process_dir + " \\ arguments.debugger.window-d.exe" ;
241+ else
242+ process_path = current_process_dir + " \\ arguments.debugger.window.exe" ;
243+
244+ // Assert that file exists
245+ if (!ra::filesystem::FileExists (process_path.c_str ()))
246+ {
247+ printf (" Start process failed. File not found: '%s'.\n " , process_path.c_str ());
248+ return false ;
249+ }
250+
251+ // Start the actual process
252+ ra::process::processid_t tmp_pid = ra::process::StartProcess (process_path, current_process_dir.c_str ());
253+
254+ // Asser created properly
255+ if (tmp_pid == 0 )
256+ {
257+ ra::errors::errorcode_t last_error = ra::errors::GetLastErrorCode ();
258+ std::string error_desc = ra::errors::GetErrorCodeDescription (last_error);
259+
260+ printf (" Start process failed. Error code %s, %s.\n " , ToHexString (last_error).c_str (), error_desc.c_str ());
261+ return false ;
262+ }
263+
264+ ra::timing::Millisleep (2000 );
265+
266+ printf (" started.\n " );
267+ pId = tmp_pid;
268+ return true ;
269+ }
270+
271+ void KillMsPaintProcess ()
272+ {
273+ printf (" Killing all mspaint.exe processes...\n " );
274+
275+ system (" cmd.exe /c taskkill /IM mspaint.exe >NUL 2>NUL" );
276+ ra::timing::Millisleep (1000 );
277+
278+ printf (" killed.\n " );
279+ }
280+
281+ bool StartMsPaintProcess (ra::process::processid_t & pId)
282+ {
283+ printf (" Starting mspaint.exe...\n " );
284+
285+ // Build path of arguments.debugger.window.exe
286+ std::string current_process_dir = ra::process::GetCurrentProcessDir ();
287+ std::string process_path = " C:\\ Windows\\ System32\\ mspaint.exe" ;
288+
289+ // Assert that file exists
290+ if (!ra::filesystem::FileExists (process_path.c_str ()))
291+ {
292+ printf (" Start process failed. File not found: '%s'.\n " , process_path.c_str ());
293+ return false ;
294+ }
295+
296+ // Start the actual process
297+ ra::process::processid_t tmp_pid = ra::process::StartProcess (process_path, current_process_dir.c_str ());
298+
299+ // Asser created properly
300+ if (tmp_pid == 0 )
301+ {
302+ ra::errors::errorcode_t last_error = ra::errors::GetLastErrorCode ();
303+ std::string error_desc = ra::errors::GetErrorCodeDescription (last_error);
304+
305+ printf (" Start process failed. Error code %s, %s.\n " , ToHexString (last_error).c_str (), error_desc.c_str ());
306+ return false ;
307+ }
308+
309+ ra::timing::Millisleep (2000 );
310+
311+ printf (" started.\n " );
312+ pId = tmp_pid;
313+ return true ;
314+ }
315+
215316 namespace FindProcessWindows
216317 {
217318 static const uint32_t ERROR_PROCESS_NOT_FOUND = (uint32_t )-1 ;
@@ -296,7 +397,7 @@ namespace shellanything
296397
297398 // Execute the action
298399 ActionExecute ae;
299- ae.SetPath (" C:\\ Windows\\ System32\\ calc .exe" );
400+ ae.SetPath (" C:\\ Windows\\ System32\\ mspaint .exe" );
300401 ae.SetBaseDir (" " );
301402 ae.SetArguments (" " );
302403
@@ -305,7 +406,7 @@ namespace shellanything
305406
306407 // Cleanup
307408 ra::timing::Millisleep (500 );
308- KillCalculatorProcess ();
409+ KillMsPaintProcess ();
309410 }
310411 // --------------------------------------------------------------------------------------------------
311412 TEST_F (TestActionExecute, testBaseDir)
@@ -324,7 +425,7 @@ namespace shellanything
324425
325426 // Execute the action
326427 ActionExecute ae;
327- ae.SetPath (" calc .exe" );
428+ ae.SetPath (" mspaint .exe" );
328429 ae.SetBaseDir (" C:\\ Windows\\ System32" );
329430 ae.SetArguments (" " );
330431
0 commit comments