Example Code

Automatically Create a TestStand User for the Windows System User in TestStand

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • Teststand

Code and Documents

Attachment

Overview

 

This example adds functionality to the default TestStand Login procedure to automatically create a new TestStand user corresponding to the current windows user if one does not exist. If you have the "Automatically Login Windows System User" Option selected in the station options, the new user will be logged in automatically.

 

Description

 

The attached example will login any Windows user with Operator privileges and therefore the login dialog will not show through the following steps:

  • Obtain the Windows System Username using a Call Executable Step to retrieve the value or the username environment variable.
  • Parse the name to remove the space at the end (since we can not create a username with a space in TestStand).
  • Create the user and insert that user into the operator group using the TestStand API.
  • Call the existing login/logout code.  If the "Automatically Login Windows System User" Station Option is enabled, the new user is automatically logged in.

 

Requirements

 

TestStand 2016 or compatible

  

Steps to Implement or Execute Code

 

If you would like this functionality, simply rename your default frontendcallbacks.seq (found in <TestStand>\Components\NI\Callbacks\FrontEnd or <TestStand>\Components\Callbacks\FrontEnd) and rename the attached file to frontendcallbacks.seq. Place the attached file in the FrontEnd folder. Now when you run the NI Sequence Editor the sequence called will have the behavior described above.

 

  1. Download and Extract the attached example
  2. Copy the FrontendCallbacks file into the following location: <TestStand Public>\Components\Callbacks\FrontEnd
  3. Close and Reopen the TestStand sequence editor.  

 

 

With warm regards,

David D.

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
smogly
Member
Member
on

hello

you write : 'The attached example (written in TestStand 4.0) will login any Windows user with Operator privileges and therefore the login dialog will not show.'

I don't see an attached document...

greets and thank you i suppose lol

kevin

Doiron
NI Employee (retired)
on

Hi smogly,

Yes I had some trouble attaching the sequence file on Friday, I apologize for any inconvenience.

I have attached a zip file with the sequence file which you may download now.

With warm regards,

David D.
PhillipBrooks
Active Participant
Active Participant
on

This idea was useful for me, thanks!

I updated it to use the .NET adapter and the System.Security.Principal.WindowsIdentity class to call GetCurrent().Name. I've attached it in TS2013 format.


Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
If you don't hate time zones, you're not a real programmer.

"You are what you don't automate"
Inplaceness is synonymous with insidiousness