cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

Call Powershell/CMD Script From a Service

Ascherer17
15-Moonstone

Call Powershell/CMD Script From a Service

Does anyone know whether it's possible to call scripts located on the server from a Thingworx Service?  Are there any Javascript objects that are available to use?  I've tried creating ActiveXObjects in a service, but it says ActiveXObject is undefined.  

We are trying to figure out how to run a Powershell script from a subscription/service.  We have Thingworx 7.1 running on a Windows server.

There's not really much of a reference for the Rhino Javascript engine.  Any ideas?

2 REPLIES 2
dupatel
19-Tanzanite
(To:Ascherer17)

@Ascherer17 Not sure if that is possible inside TWX JS service, could you please share sample code which you are trying along with the error code you are getting.

 

-Durgesh

Ascherer17
15-Moonstone
(To:dupatel)

Sorry I haven't gotten back to you.  I've heard from someone else that Thingworx is purposefully given little to no access to the OS which is understandable. 

 

One set of code I've tried as a Service:

 

var oShell = new ActiveXObject("Shell.Application");
var commandtoRun = "<filepath>.ps1"; 
oShell.ShellExecute(commandtoRun,"","","open","1");

 

When I use 'Test' feature on the service I get this error:

ReferenceError: "ActiveXObject" is not defined.

I think it's just not possible to call scripts directly from a service.

 

Announcements


Top Tags