Retrieving and Modifying the Users.ini Type Version Using the TestStand™ API

Updated Sep 16, 2026

Environment

Software

  • TestStand

Programming Language

  • C# .NET

You can use the TestStand API to programmatically retrieve and modify the type version associated with the User data type stored in the Users.ini file. This can be useful when validating custom user-management configurations, comparing user type definitions between systems, or automating configuration maintenance tasks.

 

This article demonstrates two methods for accessing and updating the User type version:

 

  • Using TestStand API calls directly from Statement steps
  • Using a .NET code module called from an Action step

 

Before modifying the User type version, create a backup of the Users.ini file and validate any changes in a non-production environment. Modifying the User type version may result in type conflict prompts if other systems or sequence files reference a different version of the User type definition.

Method 1: Using TestStand API Calls in a Statement Step

  1. Open the sequence file in TestStand.
  2. Add a Statement step to retrieve the current User type version:

Locals.CurrentVersion = RunState.Engine.UsersFile.AsPropertyObjectFile().TypeUsageList.GetTypeDefinition(0).TypeVersion

  1. Split the version string into its individual components:

Locals.Parts = Split(Locals.CurrentVersion, ".")

  1. Create a new version string by incrementing the final version component:

Locals.NewVersion = Locals.Parts[0] + "." + Locals.Parts[1] + "." + Locals.Parts[2] + "." + Str(Val(Locals.Parts[3]) + 1)

  1. Assign the updated version value to the User type definition:

RunState.Engine.UsersFile.AsPropertyObjectFile().TypeUsageList.GetTypeDefinition(0).TypeVersion = Locals.NewVersion

  1. Mark the file as modified:

RunState.Engine.UsersFile.AsPropertyObjectFile().IncChangeCount()

  1. Save the updated Users.ini file:

RunState.Engine.UsersFile.AsPropertyObjectFile().SaveFileIfModified(False)

  1. If you only need to read the currently loaded User type version without modifying the file, use:

RunState.Engine.GetTypeDefinition("User").TypeVersion

 

Method 2: Using a .NET Code Module

  1. Create a .NET Class Library project and add references to the TestStand Interop assemblies.
  2. Create a public method that accepts a SequenceContext parameter.
  3. Add code similar to the following example:
using System;
using NationalInstruments.TestStand.Interop.API;

namespace TestStandUserVersionTest
{
    public class UserVersionHelper
    {
        public static string IncrementUserTypeVersion(SequenceContext seqContext)
        {
            Engine engine = seqContext.Engine;

            UsersFile usersFile = engine.UsersFile;
            PropertyObjectFile usersPof = usersFile.AsPropertyObjectFile();
            TypeUsageList typeUsageList = usersPof.TypeUsageList;
            PropertyObject userType = typeUsageList.GetTypeDefinition(0);

            string currentVersion = userType.TypeVersion;

            string[] parts = currentVersion.Split('.');

            if (parts.Length != 4)
            {
                throw new Exception(
                    "Unexpected TypeVersion format: " + currentVersion);
            }

            parts[3] = (int.Parse(parts[3]) + 1).ToString();
            string newVersion = string.Join(".", parts);

            userType.TypeVersion = newVersion;

            usersPof.IncChangeCount();
            usersPof.SaveFileIfModified(false);

            return $"Updated User TypeVersion from {currentVersion} to {newVersion}";
        }
    }
}
  1. Build the assembly.
  2. Add an Action step in TestStand and configure it to call the .NET method.
    1. Pass ThisContext to the SequenceContext parameter.
  3. Execute the sequence and verify that the returned message reports the original and updated version values.