Over a million developers have joined DZone.

Run Command On String, Returning Output

DZone's Guide to

Run Command On String, Returning Output

· ·
Free Resource
This is basically implementing a Unix-style filter in Windows Scripting Host.

var shell = WScript.CreateObject("WScript.Shell");

var exec = shell.Exec("tr a-z A-Z");
exec.StdIn.Write("hello, world");

Watch out for deadlocks if you're writing huge amounts of data into the command, but it works for reasonable amounts of data (the buffer is probably something like 4K, but I've not tested...)

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}