Example Code

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

产品和环境

本部分要求填写创建该范例所需的产品和操作系统。

如要下载NI软件(包括以下所示产品),请访问ni.com/downloads

    软件

  • Teststand

代码和文档

添加附件

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.

NI社区“代码范例交流区”(Example Code Exchange)中的代码范例已获得MIT许可

评论
smogly
Member
Member
修改时间

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)
修改时间

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
修改时间

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.