@@ -356,10 +356,12 @@ describe("findExtraGatewayServices (win32)", () => {
356356 } ) ;
357357
358358 it ( "collects only non-openclaw marker tasks from schtasks output" , async ( ) => {
359+ // Real schtasks /Query /FO LIST /V output prefixes root-folder task
360+ // names with a backslash (e.g. TaskName:\OpenClaw Gateway).
359361 execSchtasksMock . mockResolvedValueOnce ( {
360362 code : 0 ,
361363 stdout : [
362- "TaskName: OpenClaw Gateway" ,
364+ "TaskName:\\ OpenClaw Gateway" ,
363365 "Task To Run: C:\\Program Files\\OpenClaw\\openclaw.exe gateway run" ,
364366 "" ,
365367 "TaskName: Clawdbot Legacy" ,
@@ -373,6 +375,8 @@ describe("findExtraGatewayServices (win32)", () => {
373375 } ) ;
374376
375377 const result = await findExtraGatewayServices ( { } , { deep : true } ) ;
378+ // The \OpenClaw Gateway task is the live launcher — it must be skipped.
379+ // Only the unrelated clawdbot task should be flagged.
376380 expect ( result ) . toEqual ( [
377381 {
378382 platform : "win32" ,
@@ -384,4 +388,35 @@ describe("findExtraGatewayServices (win32)", () => {
384388 } ,
385389 ] ) ;
386390 } ) ;
391+
392+ it ( "reports duplicate root tasks that only share the gateway task prefix" , async ( ) => {
393+ execSchtasksMock . mockResolvedValueOnce ( {
394+ code : 0 ,
395+ stdout : [
396+ "TaskName:\\OpenClaw Gateway" ,
397+ "Task To Run: C:\\Program Files\\OpenClaw\\openclaw.exe gateway run" ,
398+ "" ,
399+ "TaskName:\\OpenClaw Gateway (dev)" ,
400+ "Task To Run: C:\\Program Files\\OpenClaw\\openclaw.exe gateway run --profile dev" ,
401+ "" ,
402+ "TaskName:\\OpenClaw Gateway Backup" ,
403+ "Task To Run: C:\\Program Files\\OpenClaw\\openclaw.exe gateway run" ,
404+ "" ,
405+ ] . join ( "\n" ) ,
406+ stderr : "" ,
407+ } ) ;
408+
409+ const result = await findExtraGatewayServices ( { } , { deep : true } ) ;
410+ expect ( result ) . toEqual ( [
411+ {
412+ platform : "win32" ,
413+ label : "\\OpenClaw Gateway Backup" ,
414+ detail :
415+ "task: \\OpenClaw Gateway Backup, run: C:\\Program Files\\OpenClaw\\openclaw.exe gateway run" ,
416+ scope : "system" ,
417+ marker : "openclaw" ,
418+ legacy : false ,
419+ } ,
420+ ] ) ;
421+ } ) ;
387422} ) ;
0 commit comments