For those who are interested.
I got it solved an running but without tsNet functionality.
What I did is make use of the shell functionality in livecode to run a PowerShell script.
This makes it so much easier because I can run the script as a curl script (which Windows, Linux and Mac support with slight differences).
I made the following code for this which you can easaly change for running any powershell script.
The script I stored in a field (fld "CurlDeleteScript") to make sure it can be used as is (no quotes issues).
- tScripLines is the script (template) I want to run
- tScriptOutputField is used for the field where the messages need to go.
TIP: Use AI to make the script for you!
I got it solved an running but without tsNet functionality.
What I did is make use of the shell functionality in livecode to run a PowerShell script.
This makes it so much easier because I can run the script as a curl script (which Windows, Linux and Mac support with slight differences).
I made the following code for this which you can easaly change for running any powershell script.
The script I stored in a field (fld "CurlDeleteScript") to make sure it can be used as is (no quotes issues).
- tScripLines is the script (template) I want to run
- tScriptOutputField is used for the field where the messages need to go.
TIP: Use AI to make the script for you!

CODE:
Global gaStoredDataon mouseUp put fld "DocumentID" into tDocumentID put fld "DocumentName" into tDocumentName set itemdelimiter to "/" put item 2 of tDocumentName into tOnlyDocument set itemdelimiter to comma -- if tDocumentID = "" or tDocumentName = "" then answer "Missing Document ID or Document Name. Quitting!" exit MouseUp end if -- put fld "CurlDeleteScript" into ScripLines put "C:\tmp" into tAppPath // Is where temporary file is stored. -- AI_AnythingLLM_FileRemove_shell_PS ScripLines, tAppPath, tOuttScriptOutputVar, tOutMessage -- put tOutMessage into field "responseField" --end mouseUp//======================================================================// DETETE from AnythingLLM :Makescript file and let powershell run it//======================================================================command AI_AnythingLLM_FileRemove_shell_PS ScripLines, tAppPath, @tScriptOutputVar @tOutMessage if ScripLines is empty then put "Yes"into tErrorYN put "No scriptlines ???" into tOutMessage exit AI_AnythingLLM_FileRemove_shell_PS end if if tAppPath is empty then put "Yes"into tErrorYN put "No Application Path given where the temp script must be placed ???" into tOutMessage exit AI_AnythingLLM_FileRemove_shell_PS else put tAppPath into theAppPath end if -- Extracting necessary data put gaStoredData["APIKeyAnythingLLM"] into tAPIKeyAnythingLLM put gaStoredData["APIChatUrlAnythingLLM"] into tAPIChatUrlAnythingLLM put gaStoredData["APIUploadUrlAnythingLLM"] into tAPIUploadUrlAnythingLLM put gaStoredData["APIAddDeleteUrlAnythingLLM"] into tAPIAddDeleteUrlAnythingLLM put gaStoredData["APIRemoveFileUrlAnythingLLM"] into tAPIRemoveFileUrlAnythingLLM put gaStoredData["AnythingLLMWorkspace"] into tAnythingLLMWorkspace -- REPLACE placeholders in the script put fld "DocumentName" into tDocumentID // <URL> <APIKEY> <DOCID> replace "{workspace}" with tAnythingLLMWorkspace in tAPIAddDeleteUrlAnythingLLM replace "<URL>" with tAPIRemoveFileUrlAnythingLLM in ScripLines replace "<APIKEY>" with tAPIKeyAnythingLLM in ScripLines replace "<DOCID>" with tDocumentID in ScripLines -------- From here the script is agnostic --------- put the Seconds into tScriptFileName // Is a temp file excl of .ps1 extension put tScriptFileName &".ps1" into tScriptFileName if the last character of theAppPath is not "/" or the last character of theAppPath is not "\" then put "/" after theAppPath put theAppPath & tScriptFileName into thePathwithFile //replace "\" with "/" in thePathwithFile // Make all the same replace "/" with "\" in thePathwithFile // Make all the same put "file:" & thePathwithFile into tScriptFileNameGen put empty into theresult //answer tScriptFileNameGen put ScripLines into URL tScriptFileNameGen // First make the script .ps1 file that needs to be run with the powershell command! put the result into theresult if theresult is not empty then put "Error generating temp scriptfile: "&theresult into tOutMessage Put "Yes" into tErrorYN exit AI_AnythingLLM_FileRemove_shell_PS end if put tScriptFileNameGen into tScriptFileName set the hideconsolewindows to true // Disable the window console put "powershell.exe " & "powershell.exe -ExecutionPolicy ByPass -File " & thePathwithFile into tCommandstring ----- put shell(tCommandstring) into tScriptOutputVar put tScriptOutputVar into tOutMessage set the hideconsolewindows to false // Enable the window console if tOutMessage contains "success=True" then put "" else put tOutMessage into tResultMessage delete file thePathwithFile put the result into theresult if theresult is not empty or tResultMessage is not empty then put "Error : "&tScriptFileNameGen&" error message: "&theresult &lf & tResultMessage into tOutMessage Put "Yes"into tErrorYN end ifend AI_AnythingLLM_FileRemove_shell_PS
Statistics: Posted by mrcoollion — Wed Jan 22, 2025 9:15 am