Welcome!

By registering with us, you'll be able to discuss, share and exchange private messages with other members of our community.

SignUp Now!

ActiveScript for VBScript

Aug
1,826
60
Ref : SCRIPT and GetObject
Ref: Using VBScript functions from TCC22
Code:
plugin /i ActiveScript

Module:      e:\utils\ActiveScript.dll
Name:        ActiveScript
Author:      Joe Caverly
Email:       [email protected]
Web:         https://www.twitter.com/JoeC4281
Description: ActiveScript - TCC Plugin written using Purebasic
Implements:  AScript, VB
Version:     2022.12  Build 31

Version 2022-12-31

Added VB command.

The VB Command allows you to run a VBScript command, or commands.

Examples:
Code:
R:\>vb 2022-1957
65

R:\>vb CreateObject("Shell.Application").ToggleDesktop

R:\>vb DateDiff("d", "03/11/1957", Now) / 365.25
65.8069815195072

The VB command takes what you enter on the command line,
and wraps it into the following script;
Code:
  vbs = ~""
  vbs + ~"dim fso:"
  vbs + ~"set fso=CreateObject(\"Scripting.FileSystemObject\"):"
  vbs + ~"set stdout=fso.GetStandardStream(1):"
  vbs + ~"Function OutStd(txt):"
  vbs + ~"stdout.WriteLine txt:"
  vbs + ~"End Function:"
  vbs + ~"OutStd("
  vbs = vbs + theScript
  vbs + ~")"

The generated script then simply calculates your command line argument,
and sends the result to STDOUT.
----------------------------------------------------------------------
Version 2022-12-29

Initial Release.

AScript is the only command at this time.

Unlike the internal TCC Script command,
AScript works with GetObject.

Examples:
Code:
TestIt()

Function TestIt
Set fso = CreateObject ("Scripting.FileSystemObject")
Set stdout = fso.GetStandardStream (1)

Set iWMI = GetObject("WinMgmts:Root\Cimv2")
Set colItems = iWMI.ExecQuery("SELECT * FROM Win32_Process")

If Err.number <> 0 Then
  stdout.WriteLine "Error"
End if

Results = ""

For Each objItem in colItems
  Results = Results + objItem.Name + vbCrLf
Next
TestIt = Results
stdout.WriteLine TestIt
End Function

Now, run the above script;
Code:
AScript e:\utils\vince.vbs

System Idle Process
System
Secure System
Registry
smss.exe
...

AScript allows one to use Windows Scripting Components in their script;
Code:
Set oMath = GetObject("script:e:\utils\math.wsc")
 

Attachments

  • ActiveScript.7z
    17.4 KB · Views: 75
I have made additions to my ActiveScript Plugin.

README.md

The updated ActiveScript.7z can be downloaded from;

The ActiveScript.7z file was created using 7-Zip 23.01 (x64)

I have added three date commands to calculate the number of days/months/weeks from your date until today.

DateDiffd calculates the number of days from your date until today.

Examples of using datediffd;
Code:
datediffd 1960/07/08 & datediffd July 8, 1960 && datediffd 07/08/1960
23010
23010
23010

DateDiffm calculates the number of months from your date until today.

Examples of using datediffm;
Code:
datediffm 1960/07/08 & datediffm July 8, 1960 && datediffm 07/08/1960
756
756
756

DateDiffy calculates the number of years from your date until today.

Examples of using datediffy;
Code:
datediffy 1960/07/08 & datediffy July 8, 1960 && datediffy 07/08/1960
63
63
63

VBR allows the running of one or more VBScript commands or functions.

In order to output to the console, VBR begins with the following internal code;
Code:
dim fso:set fso=CreateObject("Scripting.FileSystemObject"):set stdout=fso.GetStandardStream(1):
You can now write output to the console;
Code:
vbr stdout.Write "Test" + Chr(9):a=1973:stdout.WriteLine CStr(a+1)
Test    1974

I have also added a page of VBScript One-Liners, for use with the VB command.

Joe
 
Last edited:
Back
Top