PDA

View Full Version : Execute a PowerShell .ps1 script or a PowerShell command(s)



Joe Caverly
04-04-2025, 02:23
Here's a 64-bit COM .dll that I created to execute a PowerShell .ps1 script,
or a PowerShell command(s),
from thinBasic.

GitHub - JoeC4281/PSCom: PowerShell COM dll to run .ps1 files from VBScript (https://github.com/JoeC4281/PSCom)

Here's an example use with thinBasic;

uses "Console"
' Uses "Trace"


dim ps as iDispatch
dim result as string


printl "Creating PSCom.PSScript object"


ps = CreateObject("PSCom.PSScript")


if IsComObject(ps) then
result = ps.ExecuteScript("e:\utils\winver.ps1")


printl result

result = ps.ExecuteCommand("Get-Date; 2025-1959")

Printl result
Else
Printl "Could not create PSCom.PSScript object"
end if


ps = Nothing

As this is a 64-Bit COM .dll,
you'll need to create a dllsurrogate for PSCom.dll,
so that it can be used from 32-Bit thinBasic.

Instructions for doing this are in the README.md file.

Not ready for production use,
but can be used for testing purposes.

Joe

Petr Schreiber
08-04-2025, 16:44
Hi Joe,

thank you very much for sharing the project with the community.

I appreciate the detailed README and extra transparency having the code on GitHub as well.


Petr