You can have a loop by following these screens/steps/settings in NSSM:
01) Application -----------------------------------------------------------
Path: ["%windir%\system32\cmd.exe" ]|...|
Startup directory: ["C:\path\to-bat-folder" ]|...|
Arguments: [/C "C:\path\to-bat-folder\Batch_File.bat" ]|...|
02) Details ---------------------------------------------------------------
Display name: Test batch loop
Startup type: Automatic (Delayed Star)
03) Log on ----------------------------------------------------------------
(•) Local System account [√] Allow services to interact with desktop
04) Dependencies ----------------------------------------------------------
<Blank/Nothing>
05) Process ----------------------------------------------------------------
Priority: [Normal |▼|] Affinity: [ ] All process
[√] Console windows CPUs: |◙|
|1|
|2|
|3|
06) Shutdown --------------------------------------------------------------
[√] Generate Control-C Timeout [1500 ]ms
[√] Send WM_CLOSE to windows Timeout [1500 ]ms
[√] Post WM_QUIT to threads Timeout [1500 ]ms
[√] Terminate process
07) Exit actions ----------------------------------------------------------
Delay restart if applications for runs less than [1500 ]ms
───────────────────────────────────────────────────────────────────────
Action to take when application exits [Restart application |▼|]
other than in response to a controlled
services shutdown: Delay restart by [0 ]ms
08) File rotation ---------------------------------------------------------
<Blank/Nothing>
09) Enviroment ------------------------------------------------------------
<Blank/Nothing>
10) I/O -------------------------------------------------------------------
Input (stdin): [ ]|...|
Output (stdout): ["C:\path\to-bat-folder\Name_Batch_Act_logs.log"]|...|
Error (stderr): ["C:\path\to-bat-folder\Name_Batch_Err_logs.log"]|...|
Use this code in your bat:
@echo off && cd /d "%~dp0"
:loop
"%windir%\system32\robocopy.exe" C:\Folder_A C:\Folder_B /E /MIR
"%windir%\system32\timeout.exe" /t 20 & goto :loop
About what's wrong, well, this needs to see what settings were used
It is not possible to say what it is without even seeing them.