# Using passwords in CapaInstaller VB Scripting Library

> How to use the encryption function for passwords in a script, and why it is not strong security.

Source: https://docs.capaone.com/capainstaller/vb-scripting-library/using-passwords-in-capainstaller-vb-scripting-library/  
Product: CapaInstaller — a separate CapaSystems product; do not apply this page to any other.

:::caution
Be aware that using the encryption function is not a very high level of security, It is possible to decrypt the text that has been encrypted.

To make it harder for others to decrypt the password please remove the registry value after use.
:::

:::tip
Since VBScript scripts only exist as cleartext in the database, this encryption mechanism is the only way to avoid exposing passwords directly in a script. If you can, consider building the logic as a PowerPack instead — PowerPack scripts are protected in the database in the same way, but you avoid the extra encrypt/decrypt round-trip and the associated registry value entirely.
:::

One of the problems using functions that require password, e.g. when specifying the username and password for a service account, creating a user, etc, is that the password has to be in cleartext.

Using CapaInstaller, you can overcome this problem.

Using CapaInstaller's own encryption functions, you can set the password for the user using the utility EncPassword.exe that comes with CMS. The file is located in \<ProgramFiles\>\CapaInstaller\Client\Util.

You set the password from your own computer; the utility encrypts the password and creates a registry import file (.reg file).
This registry file can be distributed and imported into all the computers within your organization that runs the CapaInstaller Client.
This utility comes with the CapaInstaller Script Editor and is installed in the same folder.

Doing this, the password is already encrypted and the user cannot see the password.
Once imported, users can use the encrypted password in CapaInstaller Scripting Library functions by specifying the character \* as the password.
The function then use the username specified in the function, and reads and decrypts the password and uses the password inside the CapaInstaller Scripting Library function.

### **Encrypting a password:**

Specify the username and password. The domain name is optional.

![](/attachments/capainstaller/e1a314b0-04f9-4a7b-8ae5-35fe28845dd6.jpg)

When imported on all your computers, you can use the functions supporting this feature.
Here is an example of the use using [Net_MapNetworkDrive](/capainstaller/vb-scripting-library/network-functions/net-mapnetworkdrive/):

**VBScript**

```vb
bStatus=True
If bStatus Then bStatus=IncludeScript("Includes.cis")
If bStatus Then bStatus=IncludeScript("customlib.cis")
If bStatus Then bStatus=IncludeScriptingLibrary("CapaInstaller Scripting Library.cin")
If bStatus Then bStatus=Job_Start("WS","Mapdrive Job","1.0","Capalib_test.log","INSTALL")
If bStatus Then bStatus=Net_MapNetworkDrive("X:","\\Server\Share",True,"Domain\Username","*")

Job_End(bStatus)
```

[Scripting Guidelines](/capainstaller/vb-scripting-library/scripting-guidelines/)

### Functions using this feature:

[Net_MapNetworkDrive](/capainstaller/vb-scripting-library/network-functions/net-mapnetworkdrive/) [Service_SetLogonInformations](/capainstaller/vb-scripting-library/service-functions/service-setlogoninformations/) [UsrMgr_CreateLocalUser](/capainstaller/vb-scripting-library/user-management-functions/usrmgr-createlocaluser/)

### Related functions

[Constants](/capainstaller/vb-scripting-library/addendum/constants/) [Package Property](/capainstaller/vb-scripting-library/addendum/package-property/) [Variables](/capainstaller/vb-scripting-library/addendum/variables/)
