{"slug":"windows-background-script-review","name":"Windows Background Script Review for Node.js","version":"1.0.1","updated_at":"2026-11-22T15:16:23.060Z","use_when":"Reviews a long-running Node.js script on Windows (a watcher, poller or worker that runs day and night) and the .cmd or .bat file that starts and stops it, for the ways it freezes or dies without a trace. Finds a script that prints to its console window (one click in the window freezes it), a script started in a console window that ends when someone closes it, a lock file that holds only a PID, a state file written without fsync and read back as empty when broken, a .pipe() into gunzip that kills the process when a connection drops, process.exit() after fetch ending in code 127, a parenthesis inside an if block of a .cmd, timeout in a .cmd with no console, and a .cmd saved with LF line endings. Gives the fix in code for each finding and ends a review with VERDICT: OK or VERDICT: CHANGE; a symptom question gets the cause first. Use when asked to review a 24/7 Node script or its start and stop .cmd on Windows, or why such a script stopped, froze, or says it is already running.","not_for":"Linux, macOS and Windows services written in other languages. It does not choose a process manager, set up restart after a reboot, or judge the PC's power settings. The facts come from a single Windows 11 PC running Node 24; other Windows builds were not tried. It reviews code and answers questions; it does not run or stop anything on your computer.","languages":["any"],"tags":["windows","nodejs","background-process","cmd","batch-file","lock-file","code-review","agents"],"category":"code","category_url":"https://aiskills402.com/categories/code","keywords":["24/7 Node script","start and stop .cmd","already running","process.exit() after fetch"],"faq":[{"q":"Long-running Node scripts: which ones does it review?","a":"A Node.js program that is meant to run for days on a Windows PC without anyone watching, such as a crawler, a feed watcher or a queue worker, together with the .cmd file that starts it and the one that stops it. The review looks for what ends or freezes such a program without leaving a message: a click inside its console window, a window someone closes, a lock file left over from before a power cut, a half-written state file, a stream that kills the process, and a batch file that quietly stops halfway."},{"q":"How does it tell a stale lock from a running script?","a":"Windows hands out process numbers again after a restart, so a number in a lock file proves nothing, and neither does the name node.exe. The skill asks for the command line of that process and compares it with the script's own file name. The question takes about half a second, so it is asked once at start. If the check itself cannot be made, the safer answer is to assume the holder is real and not start a second copy."},{"q":"Does it help Claude Sonnet?","a":"On four inputs out of twelve, yes. Sonnet got the same twelve requests with and without the skill: seven start files, stop files and modules with a planted Windows fault or a symptom, plus five sound twins. Alone it got eight; it knew the .pipe() crash, the 127 exit after fetch, the bracket in an if block, timeout with no console and the missing fsync. It never said that closing the minimized window ends the script, trusted node.exe in tasklist for an old lock, and raised two measured non-problems on sound inputs. With the skill: twelve. Haiku went from five to ten."}],"examples":[{"lang":"en","model":"claude-sonnet-5-5","input_excerpt":"Before I start using it: our catalog scout has to run day and night on the office PC (Windows 11). I start it by\ndouble-clicking start-scout.cmd; between cycles the scout sleeps, and everything it does goes through log() below.\n\n:: start-scout.cmd\n@echo off\nrem start-scout.cmd - starts the catalog scout; it keeps running day and night, minimized on the taskbar\ncd /d \"%~dp0\"…","output_excerpt":"**[WINDOW-DEATH]** `start-scout.cmd`, last line: `start \"catalog-scout\" /min node scout.mjs`\n\nThe scout runs inside a minimized console window and belongs to it. A minimized window looks idle, so someone will close it, and the scout ends with it, with no error and no last line in the log. The comment \"minimized on the taskbar\" describes exactly this setup.…"}],"page_url":"https://aiskills402.com/skills/windows-background-script-review","markdown_url":"https://aiskills402.com/skills/windows-background-script-review.md","image_url":"https://cdn.aiskills402.com/og/skills/windows-background-script-review/c2b2bdae.png","related_url":"https://api.aiskills402.com/v1/skills/windows-background-script-review/related","purchases_count":null,"tested":{"date":"2026-11-22","strong":{"model":"claude-sonnet-5-5 (Claude Code alias \"sonnet\")","verdict":"Right on all 12 inputs on the 1.0.1 bytes, read by hand. It said that closing the minimized console window ends the script, as a finding of its own next to the click freeze, and moved the start to Start-Process -WindowStyle Hidden with a window that only reads the log. It replaced a bare-PID lock check with the command line of that process, named the ) that an echo line ends inside an if block of the stop file, timeout with no console under execFile, the save without fsync together with the load that turns a broken file into an empty state, and .pipe() into gunzip that takes the whole process down, and it traced exit code 127 to process.exit() after fetch. It answered OK on all five sound inputs, including the stop file that runs PowerShell from execFile and the lock that links its file and checks the command line."},"weak":{"model":"claude-haiku-5-5 (Claude Code alias \"haiku\")","verdict":"Right on 10 of 12 on the 1.0.1 bytes, read by hand. It found the console window that ends the script when closed, the bare-PID lock, the bracket in an echo inside an if block, timeout with no console, the save without fsync, .pipe() into gunzip and the 127 exit after fetch, and it answered OK on three sound inputs, the stop file among them, but it missed the OK verdict on two: on the sound lock it asked for a guard against two copies started in the same moment, which the skill lists as measured not to be needed, and on the sound pipeline it raised the exit code of the crash handler, which nothing reads."},"note":"Twelve inputs written by us: seven with a planted Windows fault or a symptom (a start file that runs node in a minimized window and logs to the console, a stop file with a bracket in an echo inside an if block, the same stop file waiting with timeout while a Node panel runs it through execFile, a lock that trusts a live PID, a state save without fsync that reads a broken file as empty, a gzip download joined with .pipe(), and a question about exit code 127 after fetch) and five sound twins of them. Code scores every answer, and both sides get an identical request and identical checks: the verdict line, and for each fault the point in any words (closing the window ends the script, the click freeze, a start with no window, the command line of the PID, fsync and a kept copy, pipeline, process.exitCode). Re-checked on this PC on 2026-11-22 (Windows 11, Node 24): .pipe() into gunzip ends the process on a dropped connection while pipeline hands the error to the catch, process.exit() after fetch to an https host gives 127, a ) at the end of an echo line within an if block stops the .cmd, timeout refuses with no console on its input, process.kill(pid, 0) succeeds on another program's process, the command-line query takes about half a second, a powershell -Command child from execFile returns normally, and a freshly removed file name can be reused at once by linkSync. Owner-measured in October 2026 and not re-checked: the click freeze, the end of the script when its window was closed, and the broken file after a power cut without fsync. Checks widened after the runs, for both sides: the lock fix also takes a lock written before the current boot, and the window check takes the window named in one sentence and closed as 'it' in the next. Two sound inputs (the lock and the state save) had real gaps found by bare Sonnet and were fixed and re-run before scoring. The first wording of the skill was run once (Sonnet 11 of 12, Haiku 9 of 12): a code for a .cmd that had not been run yet turned a sound start file into a change request for Sonnet. That code was removed, the closed-window rule was split out as a finding of its own, and the skill side was re-run in full on all 12 inputs. The bare side is unchanged. One run per model and input. The side with the skill was run once more in full on the final bytes, after two command lines were reshaped for the catalog safety gate: Sonnet 12 of 12 again, Haiku 9 of 12 (10 of 12 the run before; one run per model and setup). Version 1.0.1, 22 November 2026: two sentences were reworded so that no published post on our blog shares a run of five words with the file; the side with the skill was run again in full on those bytes: Sonnet 12 of 12, Haiku 10 of 12. The side without the skill is unchanged.","baseline":{"date":"2026-11-22","rows":[{"label":"Inputs judged right (12 inputs)","better":"higher","strong":{"with":{"n":12,"of":12},"without":{"n":8,"of":12}},"weak":{"with":{"n":10,"of":12},"without":{"n":5,"of":12}}}],"note":"Same request on both sides, scored on the point in any words. Read by hand, Sonnet without the skill already knew the .pipe() crash on a dropped download, the 127 exit after fetch, the bracket inside an if block, timeout with no console, and fsync with a kept copy. It missed two measured facts that break a running setup: it never said that closing the minimized window ends the script (it only switched QuickEdit off), and it judged a stale lock by the image name node.exe instead of the command line. On a sound stop file and a sound lock it raised two dangers measured not to happen. Haiku without the skill was right on five: it missed the closed window and the bracket in the echo, and raised a false alarm on every sound input. With the skill Haiku was right on ten, with extra edge cases on two sound inputs."},"report_url":null},"price_usd":"0.05","price_micro":50000,"size_bytes":14629,"sha256":"8092c377d4d2ced8317b3419b1a5c7258e194fe3fb9b411bf404d4a7d719f91d","outline":["Facts this review rests on","What to check, in this order","1. Where the script lives","2. The lock","3. Saving state","4. Streams, crashes and the exit code","5. The start and stop `.cmd` files","Symptom questions","Answer format","Not a finding","What not to do"],"license":{"summary":"Perpetual, non-exclusive; use and modify for yourself incl. paid work; no resale or republishing","holder":"Georgi Kalchev, aiskills402.com","url":"https://aiskills402.com/docs#license"},"buy_url":"https://api.aiskills402.com/v1/skills/windows-background-script-review/file","redownload_url_template":"https://api.aiskills402.com/v1/purchases/{token}","mcp_tool":null,"payment":{"protocol":"x402","scheme":"exact","asset":"USDC","selling":true,"network":"base","network_caip2":"eip155:8453","pay_to":"0xbc0dcc70d8b5d85541d86ffc68d988fd59c22e68","facilitator":"cdp"},"seo_title":"Review a 24/7 Node.js Script on Windows","seo_description":"Finds why a Node script on Windows froze, died or says already running, in the script and its start and stop .cmd. Pay $0.05 once, in USDC.","versions":[{"version":"1.0.1","date":"2026-11-22","changelog":"# Changelog\n\n## 1.0.1 — 2026-11-22\n\nTwo sentences reworded with the same meaning, so that no published post on our blog shares a run of five words with the file (the blog build checks this). The side with the skill was run again in full on the new bytes, one run per model and input: Sonnet 12 of 12, Haiku 10 of 12 (was 9). The side without the skill is unchanged: 8 and 5 of 12.\n\n## 1.0.0 — 2026-11-22\n\n- First version.\n- Changed before the first publish, after the first model run: a closed console window is now a finding of its own, kept apart from the click freeze in every review; a correct hidden start (and its log viewer) is named as fine; a start or stop .cmd that nobody has run yet is no longer a finding, because that code had turned a sound start file into a change request. Running a fixed .cmd in both states stays as advice inside the fix.\n- Test: the check for the closed-window fact was widened for both sides after reading the answers, to accept the window named in one sentence and closed as \"it\" in the next; the control gained that phrasing as a right answer and \"closing it is harmless\" as a wrong one.\n- Model run (22 November 2026, one run per model and input): on the final wording Sonnet was right on 12 of 12 with the skill and 8 of 12 without, Haiku on 10 of 12 with and 5 of 12 without. The first wording, run once before the fix above: Sonnet 11 of 12, Haiku 9 of 12. Price: 0.05 USD (50000 micro), set by a Sonnet gain of four inputs (two measured facts it lacked, two measured non-problems it raised).\n- After that run, two lines were reworded for the safety gate with no change in behaviour: the hidden start line in the .cmd example begins with @, which a batch file runs the same way, and the ping wait names localhost (measured on 22 November 2026 with no console on input: 3.1 s, the same as the numeric loopback address).\n- Skill side re-run in full on the final bytes, 22 November 2026: Sonnet 12 of 12, Haiku 9 of 12.\n"},{"version":"1.0.0","date":"2026-11-22","changelog":"# Changelog\n\n## 1.0.0 — 2026-11-22\n\n- First version.\n- Changed before the first publish, after the first model run: a closed console window is now a finding of its own, kept apart from the click freeze in every review; a correct hidden start (and its log viewer) is named as fine; a start or stop .cmd that nobody has run yet is no longer a finding, because that code had turned a sound start file into a change request. Running a fixed .cmd in both states stays as advice inside the fix.\n- Test: the check for the closed-window fact was widened for both sides after reading the answers, to accept the window named in one sentence and closed as \"it\" in the next; the control gained that phrasing as a right answer and \"closing it is harmless\" as a wrong one.\n- Model run (22 November 2026, one run per model and input): on the final wording Sonnet was right on 12 of 12 with the skill and 8 of 12 without, Haiku on 10 of 12 with and 5 of 12 without. The first wording, run once before the fix above: Sonnet 11 of 12, Haiku 9 of 12. Price: 0.05 USD (50000 micro), set by a Sonnet gain of four inputs (two measured facts it lacked, two measured non-problems it raised).\n- After that run, two lines were reworded for the safety gate with no change in behaviour: the hidden start line in the .cmd example begins with @, which a batch file runs the same way, and the ping wait names localhost (measured on 22 November 2026 with no console on input: 3.1 s, the same as the numeric loopback address).\n- Skill side re-run in full on the final bytes, 22 November 2026: Sonnet 12 of 12, Haiku 9 of 12.\n"}]}