@@ -271,6 +271,27 @@ describe("installScheduledTask", () => {
271271 } ) ;
272272 } ) ;
273273
274+ it ( "omits /RU for workgroup accounts so schtasks can use the current local user" , async ( ) => {
275+ await withUserProfileDir ( async ( _tmpDir , env ) => {
276+ schtasksResponses . push ( okSchtasksResponse , missingTaskResponse ) ;
277+
278+ await installDefaultGatewayTask ( {
279+ ...env ,
280+ USERDOMAIN : "WORKGROUP" ,
281+ USERNAME : "alice" ,
282+ } ) ;
283+
284+ expectInitialTaskQueries ( ) ;
285+ const createCall = schtasksCalls [ 2 ] ;
286+ expect ( createCall ?. slice ( 0 , 5 ) ) . toEqual ( [ "/Create" , "/F" , "/TN" , "OpenClaw Gateway" , "/XML" ] ) ;
287+ expect ( createCall ) . not . toContain ( "/RU" ) ;
288+ const captured = xmlPayloadCaptures . find ( ( entry ) => entry . index === 2 ) ;
289+ expect ( captured ?. xml ) . toContain ( "<UserId>alice</UserId>" ) ;
290+ expect ( captured ?. xml ) . not . toContain ( "<GroupId>S-1-5-32-545</GroupId>" ) ;
291+ expectTaskRunCall ( 3 ) ;
292+ } ) ;
293+ } ) ;
294+
274295 it ( "re-applies the XML on /Change so upgraded tasks adopt battery flags (#59299)" , async ( ) => {
275296 await withUserProfileDir ( async ( _tmpDir , env ) => {
276297 // /Query yes, /Query /TN yes, /Change ok, /Create /XML ok (upgrade), /Run ok.
@@ -296,7 +317,9 @@ describe("installScheduledTask", () => {
296317 const upgradeCapture = xmlPayloadCaptures . find ( ( entry ) => entry . index === 3 ) ;
297318 expect ( upgradeCapture ) . toBeDefined ( ) ;
298319 const upgradeXml = upgradeCapture ?. xml ?? "" ;
299- expect ( upgradeXml ) . toContain ( "<DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>" ) ;
320+ expect ( upgradeXml ) . toContain (
321+ "<DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>" ,
322+ ) ;
300323 expect ( upgradeXml ) . toContain ( "<StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>" ) ;
301324 expectTaskRunCall ( 4 ) ;
302325 } ) ;
0 commit comments