inline-vbs
is a crate that allows you to embed VBScript, JScript and many other languages inside Rust code files. It uses
the Active Scripting COM APIs to dynamically parse and execute (optionally, evaluate) code.
use inline_vbs::*;
fn main() {
vbs! { On Error Resume Next } // tired of handling errors?
vbs! { MsgBox "Hello, world!" }
let language = "VBScript";
assert_eq!(vbs_!['language & " Rocks!"], "VBScript Rocks!".into());
}
Macros:
vbs!
- Executes a statement or evaluates an expression (depending on context)vbs_!
- Evaluates an expressionvbs_raw!
- Executes a statement (string input instead of tokens, use for multiline code) See more examples in tests/tests.rs.
Add this to your Cargo.toml
:
[dependencies]
inline-vbs = "0.4.0"
Important: You need to have the MSVC Build Tools installed on your computer, as required by cc.
VBScript (vbs!
) and JScript (js!
) are available out of the box on 32-bit and 64-bit.
Other Active Scripting engines exist:
- Ruby (
ruby!
): ActiveScriptRuby 1.8 (tested, 32-bit only)- 2.4 (32 or 64-bit) (untested!), you need to change the CLSID in src/vbs.cpp
- Perl (
perl!
): ActivePerl 5.20 (32-bit)
Note: install an engine matching the bitness of your program; by default Rust on Windows builds
64-bit programs, which can only use 64-bit libraries. If you want to use a 32-bit library, you
need to build your program with --target i686-pc-windows-msvc
.
Many.
N/A
This project is licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or https://opensource.org/licenses/MIT) at your option.