NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Add to NI_UserCustomPrivileges using API

Solved!
Go to solution

I've searched in several ways for this information and have been unsuccessful.  Is there a way to add entries to the NI_UserCustomPrivileges container--and save the changes to disk, of course?  I've found many examples of adding and deleting users and changing their privileges, but I haven't been able to find a way to add new privilege variables.

 

Thanks for your help!

0 Kudos
Message 1 of 3
(2,778 Views)
Solution
Accepted by topic author strimble

Hi strimble,

 

Assume we create two local variables, an array of Object References called "typeFileArray", and a Number called "typeIndex". Then, the following should allow you to create the type of variable you are interested in.

 

Locals.typeFileArray =

RunState.Engine.GetTypeUsageLocations("NI_UserCustomPrivileges"),


Locals.typeIndex = Locals.typeFileArray[0].AsPropertyObjectFile.TypeUsageList

.GetTypeIndex("NI_UserCustomPrivileges"),


Locals.typeFileArray[0].AsPropertyObjectFile.TypeUsageList

.GetTypeDefinition(Locals.typeIndex).SetValBoolean("HelloJohn", 1, True),


Locals.typeFileArray[0].AsPropertyObjectFile.IncChangeCount(),


Locals.typeFileArray[0].AsPropertyObjectFile.SaveFileIfModified(True)

 

 

I hope this helps!

 

John M

National Instruments
Applications Engineer
Message 2 of 3
(2,750 Views)

Thanks, John.  This works perfectly.  I didn't realize it would be so simple.  Thanks for your help!

0 Kudos
Message 3 of 3
(2,745 Views)