RemoveUser
- Last UpdatedOct 29, 2026
- 2 minute read
RemoveUser is a built-in function that removes a specified user from your project's security system.
|
Function |
Group |
Execution |
String Exp. |
Windows |
Windows Embedded |
IoT View |
Thin Clients |
Mobile Access |
|---|---|---|---|---|---|---|---|---|
|
RemoveUser |
Security |
Synchronous |
No |
Supported |
Supported |
Not supported |
Supported |
Not supported |
Syntax
RemoveUser(strUserName)
RemoveUser ( strUserName )
strUserName
The name of the user to be removed.
Return value
This function returns one of the following possible values:
|
Value |
Description |
|---|---|
|
0 |
The specified user was successfully removed. |
|
1 |
Invalid number of parameters. |
|
2 |
Wrong parameter type. |
|
3 |
The current user does not have sufficient privileges to make changes (that is, the current user does not belong to a group that has the Edit Security System option selected). |
|
4 |
The specified user cannot be removed. |
|
5 |
The specified user does not exist. |
|
6 |
Component-level failure (for example, the LDAP server returned an error). |
|
7 |
Failed to save changes to the configuration file. |
|
8 |
The current security mode does not allow the specified user to be removed. |
Notes
You can use this function to remove a user only if the Runtime user option is selected in the account settings for that user. The option is automatically selected when the CreateUser function is used to create the user, but you can also manually select the option in the User Account dialog box, if necessary. For more information, see Creating and configuring users.
You should avoid calling this function too frequently during project run time — for example, as part of a For loop that repeats in a matter of milliseconds. By default, the security settings are saved synchronously (that is, after each change is made), and too frequent saves can decrease runtime performance and/or cause the project development environment to freeze.
As a workaround, you can change the default behavior and configure your project to save the security settings asynchronously, at a specified interval. To do this, manually edit your project file (<project name>.app) to add the following settings:
[SecuritySystem]
EnableAsyncSavingForBuiltInFunctions=1
[Options]
SecuritySystemAutoSaveInterval=<in minutes, default is 5, minimum is 1>
Asynchronous saving applies to the following built-in functions:
-
BlockUser
-
CreateUser
-
RemoveUser
-
SetPassword
-
SetUserGroup
-
UnblockUser
If you enable asynchronous saving as described above and then call any of these functions to make changes to the security settings during project run time, those changes will be applied immediately but they might not be saved when the project is stopped.
In contrast, if you use the project development environment to make changes to the security settings during project run time, those changes are always saved synchronously regardless of whether asynchronous saving is enabled.
Examples
Remove the user named "Bob":
RemoveUser("Bob")
Remove the user specified by the tag InvalidUser:
RemoveUser(InvalidUser)