cmd: Introduce a WCMD_strsubstW() function to simplify string substitutions.
diff --git a/programs/cmd/batch.c b/programs/cmd/batch.c
index 0044f70..4c089ca 100644
--- a/programs/cmd/batch.c
+++ b/programs/cmd/batch.c
@@ -571,10 +571,7 @@
   if (!doneModifier) strcpyW(finaloutput, outputparam);
 
   /* Finish by inserting the replacement into the string */
-  pos = WCMD_strdupW(lastModifier+1);
-  strcpyW(*start, finaloutput);
-  strcatW(*start, pos);
-  free(pos);
+  WCMD_strsubstW(*start, lastModifier+1, finaloutput, -1);
 }
 
 /*******************************************************************