A child process receives the environment of its parent at launch time.

Every process starts with its own environment

On Windows, environment variables belong to a process. A process begins with an environment block, and a child normally receives a copy of that block when it is created. The child can then start its own children with the environment it has. This simple rule explains many cases where a command works in one window but behaves differently when another program launches it.

A terminal window, a service, a CGI handler, a Windows Script Host process, and a command interpreter are separate processes. They may have different parents, different startup times, and different environment blocks. Setting a variable in my interactive shell changes that shell and future children it launches. It does not reach sideways into an already running service or alter the environment of an unrelated CGI process.

User and machine environment settings are inputs used when processes start. Updating a persistent user or system setting does not rewrite the environment block of every running process. A long-running service must be restarted to receive updated startup settings. For a one-command change, a process-scoped override is usually easier to reason about because its lifetime is explicit.

What WshShell.Run can and cannot set

WshShell.Run accepts a command line, a window style, and a choice to wait for completion. It has no parameter for a custom environment block. The child process inherits the environment of the WSH process that calls Run. That is the supported mechanism to keep in mind: set a process variable in WSH before a synchronous Run, let the child inherit it, and restore the previous value afterward.

There is also a command-interpreter technique: start <code>cmd /c</code> with <code>set "NAME=value" &amp;&amp; command</code>. The assignment then belongs to that command interpreter and its children. This can be handy for a one-off command, but it introduces another layer of quoting and command parsing. Percent signs, ampersands, quotes, carets, and delayed expansion can change the value unless the command is constructed carefully. It is useful at a shell prompt; it is not a substitute for a clear process API when a framework already owns process creation.

In this framework, <code>os.shell.Process</code> accepts an optional environment object whose member names are variable names and whose string values are the child values. The process module records whether each variable existed and its old value, applies the overrides, calls synchronous <code>WshShell.Run</code>, then restores the original state in a finally path. The child sees the requested values; the caller resumes with its previous environment.

try-create-process compiler, parameters, 'utf-16le', {
  NODE_SKIP_PLATFORM_CHECK: '1'
}

lighttpd CGI is a separate launch path

A browser request to a local lighttpd site does not execute inside my login shell. lighttpd starts or manages a CGI process and supplies the variables required by the CGI interface, such as request metadata, the request method, and the content length. The CGI process runs under the identity configured for the server. Its PATH and inherited variables come from that service launch path and its wrapper, not from whichever terminal I used to test a command manually.

This distinction matters even on a single-user development machine. “Only I use this computer” describes who operates it; it does not collapse the process tree. The server may already be running with an older environment. A wrapper can deliberately replace PATH to limit which tools CGI can find. A command that succeeds through a full interactive PATH may therefore be missing or may resolve to a different executable inside CGI.

Tool lookup and tool environment solve separate problems. The framework's tool resolver searches the configured process PATH and its explicit tools directory setting. A process override changes variables for one launch. Adding a tools folder to a user's PATH will not repair a running service that never inherited it, and changing NODE_SKIP_PLATFORM_CHECK will not make an absent executable discoverable.

Following the failed authoring build

The authoring studio could render an unsaved article in memory, but its Build local preview action failed. Those actions did different work. In-memory preview rendered one article inside the authoring request. Building the deployed preview invoked the blog's build script, which bundled browser code and started external tools. The first action did not prove that the build toolchain could run from the CGI process.

The error page included the full chain of namespaced errors and the captured standard output and error. That detail exposed the real message: the Node runtime on this Windows host rejected its operating-system version before it ran the compiler. Running the same build from an interactive terminal succeeded because that process already had <code>NODE_SKIP_PLATFORM_CHECK=1</code>. The CGI wrapper had its own PATH and had not received the same variable through the interactive shell.

The durable fix is now at the tool boundary. The LiveScript compiler adapter asks <code>os.shell.Process</code> to run <code>lsc.cmd</code> with a scoped Node compatibility variable. Mermaid uses the same process feature for its Node-based command. Other tools do not inherit this exception merely because they are launched by the same framework. The authoring publication code stays focused on building the preview; it does not need to know how Node's platform check is configured.

A bypass is not an operating-system upgrade

<code>NODE_SKIP_PLATFORM_CHECK=1</code> tells Node to skip its startup version check. It does not add missing operating-system APIs, make an old system supported, or guarantee that every package works. I use it here because the local machine and its installed toolchain are known, the command is limited to explicit Node tools, and the failure occurred at the version gate before the compiler did useful work. A modern supported host remains the safer place to run a toolchain that relies on newer system features.

The same restraint applies to environment changes generally. A service-wide setting has a larger lifetime and affects more child processes. A process-scoped map is reviewable at the call site, can be tested with an ordinary child command, and restores the caller's state. That makes it easier to answer the practical questions: which command needs the variable, what exact value does it receive, and does the rest of the application keep its original environment?

A practical trace when a command behaves differently

I now trace the launch chain one process at a time. First I identify the executable actually resolved by the framework and the arguments it receives. Then I inspect the CGI wrapper's PATH, temporary directory, service identity, and any variables it intentionally defines. I compare those with the interactive invocation without assuming they match. If one command needs an extra variable, I pass it through the process API and verify both the child output and the restored parent value.

For captured WSH output, encoding is part of the same boundary. <code>cscript //U</code> writes Unicode output, so a parent that captures it must decode UTF-16LE. The test runner used to launch tests in Unicode mode but read the redirected output with the system code page; it could not recognize a summary that was visibly present in the raw file. Capturing it as UTF-16LE made the summary parse correctly. A byte stream can contain the right words and still be unusable if the reader assumes the wrong encoding.

Finally, I keep the complete failure context. An exit code is useful evidence, but it is not a diagnosis. The command line, child standard output, child standard error, and the namespaced error chain explain which boundary failed. Once those are visible, process environment problems stop looking like arbitrary CGI behavior and become ordinary configuration that can be reproduced and tested.