SCM as Windows Service Example
This example shows the SCM Edge Extension (SCMEXT) running as a Windows service. A Windows service is not usually configured using command line parameters, so the arguments used to configure this service are stored in the registry. These settings must be configured before the service can be installed and started.
The instructions below assume that you have installed the .NET SDK (and thereby the C SDK). In addition, it assumes that you have imported the ThingWorx Utilities Core and ThingWorx Utilities SCM Extension into your ThingWorx platform
If you are building an executable on Windows (for example, the scm_client application or this scm_service sample application, you must include the following so that the CRT or PEM file can be read from disk: #include "applink.c".
Installation Steps
1. Log in to the Windows computer.
2. Install the SCM Edge Extension, if you have not already installed it, using the tw-scm-dotnet.msi installation program.
3. Customize the scm_service.reg file for your system. The meaning of each registry key follows:
- name—The name of the Thing that you have created in ThingWorx to represent this device. This name will be the name of your device in the SCM console. The Thing should have the following Thing Template and Thing Shapes applied:
TW.RSM.Template.AssetWithTunnelsAndFileTransfer Thing Template.
TW.RSM.SFW.ThingShape.Updateable Thing Shape.
PTC.Resource.Asset.SCMResourceThingShape Thing Shape. The value of this Thing Shape will be the name of your device in the SCM console
- appKey —Generate an Application kKey using ThingWorx Composer, and copy it to this key to act as the credentials that this service should use when it connects to the platform. Alternatively, you can store the encrypted application key in the environment variable TWX_APP_KEY instead of the - appKey parameter.
- hostname—The name of the computer where your ThingWorx Platform is running. The value for this parameter is not a URL. It can be a DNS name, localhost, or a numeric IP address.
- whitelist—A path to a CSV file listing the extensions and applications used to execute scripts which have this extension.
If the whitelist cannot be found at runtime, supply the full path, enclosed in double-quotation marks. For example: "C:\Program Files (x86)\tw-scm-dotnet\
- port—The port that your ThingWorx application is using on your server. Common values are 80, 8080, or 443
- logfile—A path to which the services will have write access and in which it should create its log file.
- extPath—This is the directory in which the service can find and load the or scmext.dll, that contains the C SDK SCM Edge Extension. This is the only directory from which any Edge Extension will be loaded.
- stagingDirectory—A working directory where files will be uploaded to this device and from which scripts will be run. This directory must be writable from your service.
4. Save and close scm_service.reg.
5. Double-click the file name to load the file into your registry. When prompted, supply the administrative password.
These settings will now be present in your registry at
The installation program automatically installs the .NET service. The Thingworx SCM service should appear in the list of services in the Admin Services window. The installer does support manual installation with the /i or /u parameters being set when it is run from the command line.
6. Make sure that your service has write access to the staging directory.
Make sure that your service also has write access to the designated logging directory.
7. Create the directory listed in your stagingDirectory registry setting listed above.
8. Start your Thingworx SCM service using the Services admin tool.
9. To verify that the service is running correctly, check for a log file in the directory defined in your logFile registry setting.
Was this helpful?