Loading

Salesforce Platform: How to Configure and Run Salesforce Data Loader in Batch Mode on Windows

Дата публикации: Feb 27, 2025
Описание
Salesforce Data Loader is a tool used to import, export, insert, update, or delete large volumes of Salesforce records. By default, Data Loader runs with a graphical user interface (GUI). However, it also supports batch mode — a method of running Data Loader from the Windows Command Prompt without opening the GUI. This is useful for scheduling automated, recurring data operations. This article describes the configuration steps required to run Data Loader in batch mode on Windows, using an Insert operation as an example. Example: A Salesforce administrator needs to automatically import new Account records every night from a CSV file. Instead of manually running Data Loader each time, they configure it to run in batch mode on a schedule using Windows Task Scheduler.
Решение
  1. Open the Windows Command Prompt and navigate to the Data Loader installation directory:
  2. Generate an encryption key using any string. Replace <seedtext> with any string of your choice:
  3. Copy the output key (shown as ***) to a text file and save it as "key.txt". This key is used to encrypt your password in a later step.
  4. Navigate to the Data Loader installation directory:
  5. Generate an encryption key file. Replace <path to key file> with a directory path and file name ending in .key. If not specified, the file is saved to the default location:
  6. Verify the key file was created. Example output:
  7. Navigate to the Data Loader installation directory:
  8. Generate an encryption key file (same command as version 43/44):
  9. Verify the key file was created successfully.
  10. Create a new text file and save it with the .sdl file extension.
  11. Define the column mappings using the following syntax (left side = CSV column, right side = Salesforce field):
  12. Copy the sample process-conf.xml file from the Data Loader installation directory:
  13. Edit the file with your login details and file paths. Use the configuration sample below as a reference
Complete the following steps in order to configure and run Data Loader in batch mode.

**Step 1: Generate an Encryption Key**

An encryption key is used to encrypt (scramble for security) your Salesforce login password so it can be stored safely in the configuration file.

**For Data Loader version 42 or earlier**

   cd C:\Program Files (x86)\salesforce.com\Data Loader\bin

   encrypt.bat -g <seedtext>

   Example output: security.EncryptionUtil main (EncryptionUtil.java:304) - ***************

**For Data Loader version 43 or 44**

   cd C:\Program Files (x86)\salesforce.com\Data Loader\bin

   C:\Users\<Windows_username>\.dataloader\dataLoader.key
   Command: encrypt.bat -k <path to key file>

   Keyfile "C:\Users\<Windows Username>\.dataloader\dataLoader.key" was created!

**For Data Loader version 45 or later**

   C:\Users\<Windows Username>\dataloader\<Dataloader version>\bin

   encrypt.bat -k <path to key file>


---

**Step 2: Create an Encryption Password**

Using the encryption key from Step 1, convert your Salesforce login password into an encrypted password for use in the configuration file.

Note: The password used to log in to Data Loader is typically different from your Salesforce login password. Your Salesforce password also requires a security token (a code appended to your password for API access). See Additional Resources for how to reset your security token.

**For Data Loader version 42 or earlier**

Replace <password> with your Salesforce login password and <filepath> with the location of key.txt:
encrypt.bat -e <password> "<filepath>\key.txt"

**For Data Loader version 43 or later**

Replace <password> with your Salesforce password and provide the path to your .key file:
encrypt.bat -e <password> "C:\Users\<Windows Username>\.dataloader\dataLoader.key"

---

**Step 3: Create a Field Mapping File**

A field mapping file (.sdl) maps the columns in your input CSV file to the corresponding fields in your Salesforce object.


   SLA__C=SLA__c
   BILLINGCITY=BillingCity

For full details, see "Create the Field Mapping File" in Additional Resources.

---

**Step 4: Create the Data Loader Configuration File (process-conf.xml)**

The configuration file (process-conf.xml) is an XML file (a structured text file used to store settings) that tells Data Loader how to connect to Salesforce and where to find your data and mapping files.

   \samples\conf\process-conf.xml


   entry key=&quot;sfdc.endpoint&quot; value=&quot;https://login.salesforce.com&quot;/
   <entry key=&quot;sfdc.username&quot; value=&quot;youremail@example.com&quot;/>
   <entry key=&quot;sfdc.password&quot; value=&quot;******encryption password from Step 2******&quot;/>
   <entry key=&quot;process.encryptionKeyFile&quot; value=&quot;key.txt&quot;/>  // For version 42 and earlier
   <entry key="process.encryptionKeyFile" value="C:\Users\<Windows Username>  // For version 43+
   <entry key=&quot;process.mappingFile&quot; value=&quot;test.sdl&quot;/>
   <entry key=&quot;dataAccess.name&quot; value=&quot;test_data.csv&quot;/>
   <entry key=&quot;sfdc.debugMessages&quot; value=&quot;true&quot;/>
   <entry key=&quot;sfdc.debugMessagesFile&quot; value=&quot;testMap.sdl&quot;/>
   entry key=&quot;process.outputSuccess&quot; value=&quot;C:\test\success.csv&quot;/
   entry key=&quot;process.outputError&quot; value=&quot;C:\test\error.csv&quot;/
   <entry key=&quot;dataAccess.type&quot; value=&quot;csvRead&quot;/>

Key configuration parameters explained:
- sfdc.endpoint: Your Salesforce login URL (e.g., https://login.salesforce.com)
- sfdc.username: The username Data Loader uses to log in to Salesforce
- sfdc.password: The encrypted password generated in Step 2
- process.encryptionKeyFile: Path to the encryption key file from Step 1
- process.mappingFile: Path to the .sdl field mapping file from Step 3
- dataAccess.name: Path to the CSV data file to import
- sfdc.debugMessages: Set to true or false to enable SOAP (a protocol for exchanging data) message logging for troubleshooting
- sfdc.debugMessagesFile: Path to the file where SOAP messages are stored
- process.outputSuccess: Path to the success log file
- process.outputError: Path to the error log file
- dataAccess.type: Specifies whether Data Loader reads from or writes to a file (e.g., csvRead for input, databaseWrite for output)

For full parameter details, see "Data Loader Process Configuration Parameters" in Additional Resources.

---

**Step 5: Run the Process from the Command Line**

Once all files are configured, run the batch process from the Windows Command Prompt.

Replace <file path to process-conf.xml> with the directory containing your process-conf.xml file, and <process name> with the bean ID defined in the configuration file (the value in bean id="*****"):

process.bat "<file path to process-conf.xml>" <process name>

Once complete, Data Loader runs the specified data operation (such as Insert) from the command line without requiring the GUI.
Дополнительные ресурсы
- Run in Batch Mode (Windows Only): https://developer.salesforce.com/docs/atlas.en-us.dataLoader.meta\/dataLoader\/loader_batchmode_intro.htm
- Data Loader Command Line Introduction: https://help.salesforce.com/HTViewHelpDoc?id=command_line_intro&language=en_US
- Create the Configuration File: https://help.salesforce.com/apex/HTViewHelpDoc?id=command_line_create_config_file.htm&language=en_US
- Data Loader Process Configuration Parameters: https://help.salesforce.com/HTViewHelpDoc?id=loader_params.htm&language=en_US
- Create the Field Mapping File: https://help.salesforce.com/articleView?id=command_line_create_mapping_file.htm&language=en_US&type=0
- Reset Your Security Token: https://help.salesforce.com/HTViewHelpDoc?id=user_security_token.htm&language=en_US
Номер статьи базы знаний

000386154

 
Загрузка
Salesforce Help | Article