Squashman wrote:Would be neat if you could somehow read the clipboard memory as a file but again that would require some third party program to do that.
Internet.Explorer application and mshta (which is basically also internet explorer) have clipboardData.getData('Text') method (example taken from einstein1969):
Code: Select all
for /f "usebackq tokens=1,* delims=[]" %i in (`mshta "javascript:close(new ActiveXObject('Scripting.FileSystemObject').GetStandardStream(1).Write(clipboardData.getData('Text')));"^|find /v /n ""`) do @set "c[%i]=%j"
Though I think its too much.
Here's one pretty simple VBExecutor.bat :
Code: Select all
@echo off
for %%# in (-h /h /help -help) do (
if "%~1" equ "%%~#" (
(echo()
echo Executes vbscript statements
(echo()
echo Usage:
echo %~nx0 statement [statement]
(echo()
echo double quotes in ststements must be replaced with single quotes
echo in ordred to avoid collision with command line arguments
(echo()
echo example:
echo call %~nx0 "Wscript.Echo('example')" "WScript.Sleep(3000)"
exit /b 0
)
)
cscript /noLogo "%~f0?.WSF" //job:execute %*
exit /b %ErrorLevel%
<job id="execute">
<script language="VBScript">
For i=0 to WScript.Arguments.Count-1
Execute(Replace(WScript.Arguments.Item(i),"'","""")):
Next
</script>
</job>
Which will iterate through the arguments and will execute them. For strings you'll need to use single quote instead of double quote to avoid the mess with VBScript strings and arguments enclosing with double quotes.It is not bulletproof but for one liners is ok I think:
Code: Select all
call VBExecutor "Wscript.Echo('ZzZ')" "WScript.Sleep(3000)"
Probably I should option (with named arguments) that will switch between Eval,Execute,ExecuteGlobal ?