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

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

Call Powershell/CMD Script From a Service

Ascherer17
14-Alexandrite

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
14-Alexandrite
(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.

 

Top Tags