Code Monkey home page Code Monkey logo

run-vbs's Introduction

Node RunVbs

A simple package to run VBS scripts from NodeJs.

NPM link: @el3um4s/run-vbs

Install and use the package

To use the package in a project:

npm i @el3um4s/run-vbs

and then in a file:

import { runVbs, runVbsFile } from "@el3um4s/run-vbs";

const vbs = `Wscript.Echo "hello world"`;
const result = await runVbs({ vbs });
console.log(result); // hello world

const file = "./test.vbs";
const fromFile = await runVbsFile({ vbs: file });
console.log(fromFile); // hello world

API: runVbs

  • runVbs(data: { vbs: string; args?: string[]; }): Promise<string> Run a VBS script and return the result.
  • runVbsBuffer(data: { vbs: string; args?: string[]; }): Promise<string[]> Run a VBS script and return the result as a buffer.
import { runVbs } from "@el3um4s/run-vbs";

const vbs = `
set args = Wscript.Arguments

Dim name, surname

Dim count
count = WScript.arguments.count

if count = 0 then
    name = ""
    surname = ""
    Wscript.Echo "hello world"
end if

if count = 1 then
    name = args(0)
    surname = ""
    Wscript.Echo "hello" & " " & name & "!"
end if

if 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 world

const result2 = await runVbs({
  vbs,
  args: ["John", "Doe"],
});
console.log(result2); // hello John Doe!

API: runVbsFile

  • runVbsFile(data: { vbs: string; args?: string[]; }): Promise<string> Run a VBS script and return the result.
  • runVbsFileBuffer(data: { vbs: string; args?: string[]; }): Promise<string[]> Run a VBS script and return the result as a buffer.
import { runVbsFile } from "@el3um4s/run-vbs";

const result = await runVbsFile({
  vbs: "./src/__tests__/test_no_output.vbs",
});
console.log(result); // hello world

const 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:

run-vbs's People

Contributors

el3um4s avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.