Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

WSHModule is a JavaScript virtual machine built in WSH/JScript.

NotificationsYou must be signed in to change notification settings

polygonplanet/WSHModule

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

66 Commits
 
 
 
 
 
 

Repository files navigation

WSHModule is a JavaScript virtual machine built in WSH/JScript.

It is a subset of the JavaScript interpreter that supports to compatible with the ECMAScript 5 standard in WSH/JScript.WSHModule's script run at module scope (CommonJS/UMD) that means it can userequire,exports andmodule objects.WSHModule can assist to upgrade JScript in Windows Script Host as much as possible to approach the ECMA-262 standard.

Possibly, better to use Node.js it would be quickly.However, JScript has been bundled with Windows.Improves a local environment when run a batch script with extension "js" by the passage to WSHModule.

Compatibility

  • Windows (32bit/64bit)

WSHModule will work with WSH version 5.6 or later.

Currently, WSHModule does not use file type association and Windows environment (eg., PATH).

Features

WSHModule supports the following features:

  • Supports ECMAScript5 standard syntax.
  • Supports CommonJS Universal Module Definition (UMD).
  • Working with UTF-8 encoding.
  • Supports standard DOM functions: alert/confirm/prompt, setTimeout/clearTimeout and setInterval/clearInterval.
  • Supports a console window.
  • Fixed JScript bug: try-finally statements, String.prototype.substr, Array.indexOf and Array.prototype.splice functions to standard ECMA-262.

Quickstart usage

Runs script with WSHModule:

WSHModule.exe "C:/path/to/myscript.js"

or

Execute (drag-drop)C:/path/to/myscript.js toWSHModule.exe

Simple way:

  1. Create a shortcut of WSHModule.exe to desktop.
  2. Execute script by drag-drop to shortcut.

Tests

Runs test script:

  1. cd WSHModule
  2. "bin/WSHModule.exe" "scripts/test.js"

ToDo

  • Getter andSetter support.
  • "use strict" syntax support.

Dev

  • bin/src/WSHModule is built on Lazarus (Free Pascal)

Build

  1. Copybin/wshmodule.wsf andbin\wshmshell.js tobin/src/WSHModule folder
  2. DownloadLazarus IDE and Install
  3. Project -> Open Project -> Openbin/src/WSHModule/WSHModule.lpr (ChangeAll files (*.*))
  4. Confirm dialogThe file "WSHModule.lpr" is not a Lazarus project. Create a new project for this "program"? ->Create project
  5. SelectApplication
  6. Run (MenuRun -> Run) orBuild (MenuRun -> Build)

You can get aWSHModule.exe by build, and also run JavaScript with WSHModule console, for example, typing1+1 and press enter key in the console window, you can get result2.

JavaScript API

Global

  • __filename : Current filename
  • __dirname : Current dirname

Example

console.log(__filename);// C:\path\to\your_script.jsconsole.log(__dirname);// C:\path\to

Clipboard

Example

varclip=require('clip');clip.set('test');

Available format: 'text' or 'html'

  • get ([format = 'text']) : Get clipboard text as [format]
  • set (data, [format = 'text']) : Set data to clipboard as [format]
  • empty() : Empty clipboard data
  • hasFormat(format) : Check whether clipboard has a format
  • getAsText() : A shortcut ofget('text')
  • getAsHTML() : A shortcut ofget('html')
  • setAsText(data) : A shortcut ofset(data, 'text')
  • setAsHTML(data) : A shortcut ofset(data, 'html')
  • copy() : Emulate copy command of the keyboard
  • paste() : Emulate paste command of the keyboard
  • cut() : Emulate cut command of the keyboard
  • getSelectedText() : Get selected text to clipboard (shortcut ofcopy() andget())
  • print(text) : Print clipboard text (shortcut ofset(text) andpaste())

fs

Local file system utility

varfs=require('fs');console.log(fs.readFileSync('./test.txt'));
  • renameSync(oldPath, newPath) : Rename fileoldPath tonewPath
  • statSync(path) : Get file stat
  • unlinkSync(path, force = false) : Remove file
  • existsSync(path) : Check whether a file exists
  • readFileSync(filename, encoding = 'utf-8') : Read content fromfilename
  • writeFileSync(filename, data, encoding = 'utf-8') : Write contentdata tofilename
  • copySync(src, dst, overwrite = false) : Copy filesrc todst
  • moveSync(src, dst) : Move file fromsrc todst

License

MIT

Credits

This project is using on the following excellent free yet copyrighted open source softwares. We follow the policies of those software packages.

About

WSHModule is a JavaScript virtual machine built in WSH/JScript.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp