- Aug
- 2,799
- 144
I am naive when it comes to C++,
but CoPilot helped me in creating simple C++ code,
that demonstrates executing a PowerShell Command,
which I compiled,
and successfully executed.
Compiled;
Results of execution;
If I remember correctly,
TCC cannot be compiled using the /clr switch,
the /clr switch meaning "Enables applications and components to use features from the common language runtime (CLR) and enables C++/CLI compilation."
Keeping that in mind,
can TCC use a plugin that was compiled using the /clr switch?
If so,
would this be the start of a solution,
to allow C++ / Powershell integration with TCC?
Joe
but CoPilot helped me in creating simple C++ code,
that demonstrates executing a PowerShell Command,
which I compiled,
and successfully executed.
C++:
#using <mscorlib.dll>
#using <System.Management.Automation.dll>
#include <iostream>
#include <string>
#include <msclr\auto_handle.h>
using namespace System;
using namespace System::Management::Automation;
using namespace System::Collections::ObjectModel;
void ExecutePowerShellCommand(String^ script) {
// Create a PowerShell instance
PowerShell^ ps = PowerShell::Create();
ps->AddScript(script);
// Execute the script and retrieve results
Collection<PSObject^>^ results = ps->Invoke();
// Output results
for each (PSObject^ result in results) {
Console::WriteLine(result->ToString());
}
}
int main() {
// PowerShell script to execute
String^ script = "Get-Date";
// Call the function to execute the script
ExecutePowerShellCommand(script);
return 0;
}
Compiled;
Bash:
R:\>#cl /clr test.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.42.34438
for Microsoft (R) .NET Framework version 4.08.9290.0
Copyright (C) Microsoft Corporation. All rights reserved.
test.cpp
Microsoft (R) Incremental Linker Version 14.42.34438.0
Copyright (C) Microsoft Corporation. All rights reserved.
/out:test.exe
test.obj[/COLOR]
Results of execution;
Bash:
2025-03-16 12:35:56 PM[/COLOR]
If I remember correctly,
TCC cannot be compiled using the /clr switch,
the /clr switch meaning "Enables applications and components to use features from the common language runtime (CLR) and enables C++/CLI compilation."
Keeping that in mind,
can TCC use a plugin that was compiled using the /clr switch?
If so,
would this be the start of a solution,
to allow C++ / Powershell integration with TCC?
Joe
Last edited: