Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: add copy node executable guide on windows #47781

Closed
wants to merge 11 commits into from
44 changes: 40 additions & 4 deletions doc/api/single-executable-applications.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,29 @@ tool, [postject][]:
```

4. Create a copy of the `node` executable and name it according to your needs:

* On systems other than Windows:

```console
$ cp $(command -v node) hello
```

* On Windows:

Using PowerShell:

```console
$ cp (Get-Command node).Source hello.exe
```

Using Command Prompt:

```console
$ for /F "tokens=*" %n IN ('where.exe node') DO @(copy "%n" hello.exe)
```

The `.exe` extension is necessary.

5. Remove the signature of the binary (macOS and Windows only):

* On macOS:
Expand All @@ -61,13 +80,14 @@ tool, [postject][]:
skipped, ignore any signature-related warning from postject.

```console
$ signtool remove /s hello
$ signtool remove /s hello.exe
```

6. Inject the blob into the copied binary by running `postject` with
the following options:

* `hello` - The name of the copy of the `node` executable created in step 2.
* `hello` / `hello.exe` - The name of the copy of the `node` executable
created in step 4.
* `NODE_SEA_BLOB` - The name of the resource / note / section in the binary
where the contents of the blob will be stored.
* `sea-prep.blob` - The name of the blob created in step 1.
Expand All @@ -79,12 +99,18 @@ tool, [postject][]:

To summarize, here is the required command for each platform:

* On systems other than macOS:
* On Linux:
```console
$ npx postject hello NODE_SEA_BLOB sea-prep.blob \
--sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2
```

* On Windows:
```console
$ npx postject hello.exe NODE_SEA_BLOB sea-prep.blob \
--sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2
```

* On macOS:
```console
$ npx postject hello NODE_SEA_BLOB sea-prep.blob \
Expand All @@ -106,15 +132,25 @@ tool, [postject][]:
binary would still be runnable.

```console
$ signtool sign /fd SHA256 hello
$ signtool sign /fd SHA256 hello.exe
```

8. Run the binary:

* On systems other than Windows

```console
$ ./hello world
Hello, world!
```

* On Windows

```console
$ .\hello.exe world
Hello, world!
```

## Generating single executable preparation blobs

Single executable preparation blobs that are injected into the application can
Expand Down