https://github.com/el3um4s/run-vbs
Run .vbs script with node
https://github.com/el3um4s/run-vbs
cscript cscripts node node-js nodejs vbs vbscript vbscript-script windows
Last synced: 2 months ago
JSON representation
Run .vbs script with node
- Host: GitHub
- URL: https://github.com/el3um4s/run-vbs
- Owner: el3um4s
- License: mit
- Created: 2022-07-12T21:24:19.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-01-09T01:56:57.000Z (over 2 years ago)
- Last Synced: 2025-03-14T23:36:54.612Z (3 months ago)
- Topics: cscript, cscripts, node, node-js, nodejs, vbs, vbscript, vbscript-script, windows
- Language: TypeScript
- Homepage:
- Size: 849 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Node RunVbs
A simple package to run VBS scripts from NodeJs.
NPM link: [@el3um4s/run-vbs](https://www.npmjs.com/package/@el3um4s/run-vbs)
### Install and use the package
To use the package in a project:
```bash
npm i @el3um4s/run-vbs
```and then in a file:
```ts
import { runVbs, runVbsFile } from "@el3um4s/run-vbs";const vbs = `Wscript.Echo "hello world"`;
const result = await runVbs({ vbs });
console.log(result); // hello worldconst file = "./test.vbs";
const fromFile = await runVbsFile({ vbs: file });
console.log(fromFile); // hello world
```### API: runVbs
- `runVbs(data: { vbs: string; args?: string[]; }): Promise` Run a VBS script and return the result.
- `runVbsBuffer(data: { vbs: string; args?: string[]; }): Promise` Run a VBS script and return the result as a buffer.```ts
import { runVbs } from "@el3um4s/run-vbs";const vbs = `
set args = Wscript.ArgumentsDim name, surname
Dim count
count = WScript.arguments.countif count = 0 then
name = ""
surname = ""
Wscript.Echo "hello world"
end ifif count = 1 then
name = args(0)
surname = ""
Wscript.Echo "hello" & " " & name & "!"
end ifif count = 2 then
name = args(0)
surname = args(1)
Wscript.Echo "hello" & " " & name & " " & surname & "!"
end if
`;const result = await runVbs({
vbs,
});
console.log(result); // hello worldconst result2 = await runVbs({
vbs,
args: ["John", "Doe"],
});
console.log(result2); // hello John Doe!
```### API: runVbsFile
- `runVbsFile(data: { vbs: string; args?: string[]; }): Promise` Run a VBS script and return the result.
- `runVbsFileBuffer(data: { vbs: string; args?: string[]; }): Promise` Run a VBS script and return the result as a buffer.```ts
import { runVbsFile } from "@el3um4s/run-vbs";const result = await runVbsFile({
vbs: "./src/__tests__/test_no_output.vbs",
});
console.log(result); // hello worldconst result2 = await runVbsFile({
vbs: "./src/__tests__/test_no_output.vbs",
args: ["John", "Doe"],
});
console.log(result2); // hello John Doe!
```### Known Issues
There can be issues when the file path has a space.
### Acknowledgments
To create this package I was inspired by:
- [windows-shortcut-vbs](https://www.npmjs.com/package/windows-shortcut-vbs)
- [el3um4s/deno-adodb](https://github.com/el3um4s/deno-adodb)