NK2Edit Command-Line Options

In the following section you can find the list of all command-line options available in NK2Edit utility:

/nk2file <Filename> Start NK2Edit with the specified .NK2 filename. If you don't use this command-line option, the .NK2 file of the default Outlook profile is loaded.
/nk2_to_text <NK2 Filename> <Text Filename> Convert NK2 file into a raw text file that can be edited with any Unicode text editor. After editing the file, you can convert it back into a valid NK2 file by using /text_to_nk2 command-line option.
/text_to_nk2 <Text Filename> <NK2 Filename> convert a raw text file back into a valid NK2 file.
/import_full_nk2 <NK2 Filename> Imports all records of the specified nk2 file into the AutoComplete file of the default Outlook profile. Be aware that this action overwrites all the existing AutoComplete records with the records of the specified nk2 file.
/export_to_message_store <.dat AutoComplete Filename> This command-line option is only relevant for Outlook 2010/2013 and possibly future versions of Outlook. Starting from Outlook 2010, the AutoComplete data is stored in 2 different locations: Inside a simple AutoComplete file on the local disk, like it was in all previous versions of Outlook, and inside the message store where all Outlook data is stored. In MS-Exchange profiles, a copy of the AutoComplete data is stored in the remote Exchange server. In profiles based on .pst file, the AutoComplete data is stored in the .pst file. In some circumstances, the copy of the AutoComplete data stored in the message store of Exchange Server 2010 may overwrite the changes you made with NK2Edit. This command-line option allows you to export the AutoComplete file into the message store of the default Outlook profile, so the copy of the AutoComplete data stored in the MS-Exchange server will not overwrite your changes.

Example:
NK2Edit.exe /export_to_message_store $default

/AutoExportToMessageStore <0 | 1> Specifies whether to automatically export the AutoComplete data into the message store of the default Outlook profile, every time that the AutoComplete is saved. 0 = No, 1 = Yes. You can use this command-line option together with /script and all other command-line options. It's highly recommended to use '/AutoExportToMessageStore 1' if you have Outlook 2010 or greater version.
Be aware that setting AutoExportToMessageStore to 1 only works when you save the default AutoComplete file.
/import_from_message_store <AutoComplete Filename> Saves the AutoComplete data stored inside the message store (PST file or Exchange server) of the current Outlook profile to the specified file. (This option is the opposite of /export_to_message_store )

Example:
NK2Edit.exe /import_from_message_store "c:\temp\import1.dat"

/WarnIfOutlookRunning You can use this command-line switch with /script , /script_express , and other command-line options to warn the user if Outlook is running.
/SetOutlookMaxRecords <Maximum Records> This option allows you to easily change the maximum numbers of AutoComplete records allowed by Outlook. NK2Edit automatically detects the current installed version of Outlook and updates the correct Registry value.
/CompleteMessage <Message Text> Instructs NK2Edit to display a message to the user when a command-line action is completed, for example:
NK2Edit.exe /CompleteMessage "Finished executing the script of NK2Edit" /LogFile "express_log.txt" /script_express $default 'If AddressType equal "EX" EXToSMTP' 'If Domain Equal "gmail.com" Delete'
/SkipCommandLineNoProfiles If it's set to 1, then the /script, /script_express, and /export_to_message_store commands will not do anything if there are no Outlook profiles on the computer you run it, for example:
NK2Edit.exe /SkipCommandLineNoProfiles 1 /LogFile "express_log.txt" /script_express $default 'If AddressType equal "EX" EXToSMTP' 'If Domain Equal "gmail.com" Delete'
/TimestampBackup You can use this command-line switch with /script , /script_express , and other command-line options to create a separated backup every time that the command-line is executed. The backup filename is generated with a timestamp, for example: 1.nk2.20130813111927.NK2Edit.bak
/nofirstbackup By default, /text_to_nk2 and /script options automatically backup the nk2 if it's the first overwrite made by NK2Edit. If you don't want to create a backup, use /nofirstbackup parameter.
/nobackup By default, /text_to_nk2 and /script options automatically backup the nk2 file on every save, into a filename with .NK2Edit.Cmd.bak extension. If you don't want to create this backup, use /nobackup parameter.
/script <Script Filename> <NK2 Source> <NK2 Destination> Allows you to run a simple script that can make changes, like adding new NK2 records, replacing values in existing records, or deleting unwanted records without displaying any user interface. The <Script Filename> parameter specifies the filename contains the script. The <NK2 Source> is the NK2 filename to load, and the <NK2 Destination> is the NK2 file to save your changes. If <NK2 Destination> is not specified, your changes will overwrite the filename specified in <NK2 Source> parameter.

For more information about scripting with NK2Edit, read this page.

/script_express <NK2 File> 'Script Line 1' 'Script Line 2' 'Script Line 3' ... Allows you to run a simple script, like /script , but without using external script file.

For more information about scripting with NK2Edit, read this page.

/ScriptInput <Input Filename> Allows you to create a script with parameters, and the parameter values are loaded from the specified input file. The input file is comma-delimited (csv) or tab-delimited file. In the script file, a parameter is specified as *X. *0 for the first parameter, *1 for the second paramter, *2 for the third parameter, and so on (up to 10 parameters)

Example for script line with parameters:
if Email Equal "/o=Domain/ou=First Administrative Group/cn=Recipients/cn=*0" set Email "/o=Domain/ou=First Administrative Group/cn=Recipients/cn=*1" AutoFill

Example for the input filename:
user01, newuser01
user02, newuser02
user03, newuser03
user04, newuser04

If you run the above script line with the above input file, /o=Domain/ou=First Administrative Group/cn=Recipients/cn=user01 will be replaced with /o=Domain/ou=First Administrative Group/cn=Recipients/cn=newuser01 and so on..

You can create the input file as Ascii file or Unicode file.

/copy_default <Destination File> (Available only in licensed version)

Allows you to easily copy the NK2 file of the default profile into the specified destination filename. The default NK2 filename may be different from one computer to another, depending on the profile name and Outlook version, so this option provide you an easily way to backup/copy the NK2 file into another location.

You can use this command-line option to collect the NK2 files from all computers on your network, by using it in the logon script of Windows, for example:
NK2Edit.exe /copy_default "z:\nk2files\%computername%.nk2"
NK2Edit.exe /copy_default "z:\nk2files\%username%.nk2"

/RestoreBackup {Backup File Extension} Restores the last backup made by NK2Edit on the default AutoComplete File. By default, this command restores the backup made by NK2Edit scripts, with .NK2Edit.Cmd.bak extension.
Optionally you can specify .NK2Edit.bak extension (backup made from user interface) or NK2Edit.First.bak extension (First backup made by NK2Edit) if you want to restore other type of backup, for example:
NK2Edit /RestoreBackup .NK2Edit.bak
/export_to_contacts <Source NK2 File> (Available only in licensed version)

Allows you to export all emails stored inside the specified NK2 directly into the contacts of Outlook. If an email already exist, it won't be added again, in order avoid from duplicate contacts.
In <Source NK2 File> - you can also specify $default if you want to use the NK2 of the default Outlook profile.

Example:

  • NK2Edit.exe /export_to_contacts "f:\temp\myfile.nk2"
  • NK2Edit.exe /export_to_contacts $default
/generate_new_nk2 <Destination NK2 File> <Number Of Days> <Max Emails> <Sent Messages> <Received Messages> (Available only in licensed version)

Allows you to generate a completely new NK2 file from the email addresses found in your mailbox. When using this command-line option, NK2Edit scans the messages inside your mailbox, collects the email addresses, and then generates a completely new NK2 file with all email addresses found in the mailbox scan process.

Here's the description of the parameters:

  • Destination NK2 File: The NK2 file to save the collected emails list. If you specify $default, the NK2 file of the default Outlook profile will be overwritten.
  • Number Of Days: Specify the number of days to scan backward from the current date. For example: If you specify 60 in this parameter, NK2Edit will scan the email messages created in the last 60 days.
  • Max Emails: Maximum number of email addresses to collect. Be aware that the default maximum number of records in NK2 file is 1000 for Outlook 2003 and 2000 for Outlook 2007/2010. So it's recommended to keep this parameter value below these limits.
  • Sent Messages: Specifies whether to scan the email addresses in the messages you sent. 1 = Yes, 0 = No.
  • Received Messages: Specifies whether to scan the email addresses in the messages you received. 1 = Yes, 0 = No. It's recommended to set this parameter value to 0 in most cases, because when you set it to 1, email addresses of spam messages might be added into the created NK2 file.

Example:

  • Scan the email addresses of messages sent in the last 60 days, and stop the scan process after finding 500 email addresses. Save the found email addresses into myfile.nk2
    NK2Edit.exe /generate_new_nk2 "f:\temp\myfile.nk2" 60 500 1 0

Notice: For using this command-line option with 64-bit version of Outlook 2010, you must use the x64 version of NK2Edit. In all other cases, you should use the 32-bit version of NK2Edit.

/import_address_book <NK2 Filename> <Address Book Name> <Address Type> <MaxRecords> (Available only in licensed version)

Allows you to import the addresses stored inside the Contacts/Address Book of Outlook directly into your NK2 file.

Here's the description of the parameters:

  • NK2 Filename: The NK2 file to import the addresses. If the file already exists, the email addresses from the contacts/address book will be added into the existing NK2 file. If the email addresses already exist in the NK2 file, they'll be merged with the address book emails according to the merge mode defined in the config file. If the specified NK2 file doesn't exist, a completely new NK2 file with all the contacts addresses will be created.
    You can also specify $default for this parameter if you want to use the NK2 file of the default Outlook profile.

  • Address Book Name: The name of the address book to import. You must specify the exact name, as displayed in the address book window of Outlook:

    For non-Exchange Outlook profiles, this parameter should be "Contacts", which means that the email addresses from the Contacts folder of Outlook will be imported into the NK2 file.
    For Exchange profiles, you can also specify other address books, like "Global Address List", "Personal Address Book", "All Users", and a few others.
  • Address Type: Specifies the type of addresses to import. You can specify SMTP (for SMTP addresses), EX (for Exchange addresses), or All (for both SMTP and EX addresses).
    You can also specify multiple address types delimited by '+' character, for example: MAPIPDL+EX+SMTP
  • MaxRecords: Maximum number of records that will be added to the NK2 file. It's recommended to set this value to the default of Outlook, which is 1000 for Outlook 2003, and 2000 to Outlook 2007/2010.

Examples:

  • Add the SMTP addresses from the Contacts of Outlook into the NK2 file of the default Outlook profile:
    NK2Edit.exe /import_address_book $default "Contacts" "SMTP" 2000
  • Add all addresses from the 'Personal Address Book' of Outlook (in Exchange profile) into personal.nk2 file.
    NK2Edit.exe /import_address_book personal.nk2 "Personal Address Book" "All" 2000
  • Add EX, SMTP, and MAPIPDL addresses from 'NirSoft Address Book' into the AutoComplete file of the default Outlook profile:
    NK2Edit.exe /import_address_book $default "NirSoft Address Book" "MAPIPDL+EX+SMTP" 2000

Notice: For using this command-line option with 64-bit version of Outlook 2010, you must use the x64 version of NK2Edit. In all other cases, you should use the 32-bit version of NK2Edit.

/sync_address_book <NK2 Filename> <Address Book Name> <Address Type> <MaxRecords> (Available only in licensed version)

This command line option is very similar to /import_address_book , but with one additional action: /sync_address_book also deletes from the NK2 file all addresses that cannot be found inside the specified address book/contacts list. So if a contact was removed from the address book, it'll also be removed from the NK2 file. Be aware that only the records with the specified Address Type will be removed from the NK2 file. For example, if you specify 'Ex' as the address type, all Exchange emails that cannot be found in the address book will be removed, but the SMTP addresses won't be deleted.

Examples:

  • Synchronize the Exchange addresses in the NK2 file with the Global Address List of Outlook/Exchange, but leave all SMTP records without change.
    NK2Edit.exe /sync_address_book $default "Global Address List" "EX" 2000
/import_csv_file <NK2 Filename> <CSV File> <Merge Mode> (Available only in licensed version)

Allows you to import addresses from a simple comma-delimited (csv) text file. For more information about the structure of this file, read this page: Import NK2 addresses from a simple comma-delimited (csv) text file

Here's the description of the parameters:

  • NK2 Filename: The NK2 file to import the addresses. If the file already exists, the contacts in the specified .csv file will be merged into the nk2 file, according to the specified merge mode. If the file doesn't exist, a new NK2 file will be created. You can also specify $default in order to use the NK2 file of the default Outlook profile.
  • CSV File: The .csv file containing the names/emails information.
  • Merge Mode: Specify one of the following values:
    • 1 - Allow duplicate records
    • 2 - (Recommended) If email already exist, replace it with the new one.
    • 3 - If email already exist, don't add the record.

Examples:

  • NK2Edit.exe /import_csv_file $default "c:\files\users.csv" 3
  • NK2Edit.exe /import_csv_file "c:\temp\1.nk2" "c:\files\users.csv" 2
/import_contacts_file <NK2 Filename> <Contacts File> <Merge Mode> (Available only in licensed version)

Allows you to import addresses from the contacts .csv file of Microsoft Outlook into your .NK2 file. You can create this contacts .csv file by using the export feature of Outlook. Others email software and services, like Gmail and Yahoo, also allows you to export the contacts into a .csv file that is compatible with Microsoft Outlook, so you can also use this command-line option to import contacts of Gmail/Yahoo into your NK2 file.

Here's the description of the parameters:

  • NK2 Filename: The NK2 file to import the addresses. If the file already exists, the contacts in the specified .csv file will be merged into the nk2 file, according to the specified merge mode. If the file doesn't exist, a new NK2 file will be created. You can also specify $default in order to use the NK2 file of the default Outlook profile.
  • Contacts File: The .csv file contains the contacts that you wish to import. This file must be compatible with the contacts export feature of Microsoft Outlook.
  • Merge Mode: Specify one of the following values:
    • 1 - Allow duplicate records
    • 2 - (Recommended) If email already exist, replace it with the new one.
    • 3 - If email already exist, don't add the record.

Examples:

  • NK2Edit.exe /import_contacts_file $default "c:\contacts\mycontacts.csv" 3
  • NK2Edit.exe /import_contacts_file "c:\temp\1.nk2" "c:\contacts\gmail_contacts.csv" 2
/logon_profile <Outlook Profile Name>

This command-line parameter tells NK2Edit to use the specified Outlook profile for any Contacts/Mailbox scan action, instead of using the default profile.
You can use this command-line parameter together with /import_address_book , /export_to_contacts, and /generate_new_nk2 command-line options, if you want to make the action with another Outlook profile. For example, if you want to import the contacts located inside Outlook2 profile into your default NK2 file:
NK2Edit.exe /import_address_book $default "Contacts" "SMTP" 2000 /logon_profile "Outlook2"

/merge_files <Destination File> <Source File 1> <Source File 2> <Merge Mode> <MaxRecords> <Weight Mode> (Available only in licensed version)

Allows you to merge 2 NK2 files into one from command-line. The file you specify in <Source File 2> is merged into <Source File 1> and then the result is saved into the file your specify in <Destination File>. If <Source File 1> or <Source File 2> is specified as an empty string (""), the <Destination File> will be used as a source.

Here's the description of the parameters:

  • Destination File: The .nk2 file to save the final result.
  • Source File 1 and Source File 2: The 2 NK2 files to merge. The file in 'Source File 2' is merged into the file specified in 'Source File 1'. You can specify $default if you want to use the NK2 file of the default profile as a source. You can specify empty string ("") if you want to use the destination file as a source.
  • Merge Mode: Specify one of the following values:
    • 1 - Allow duplicate records
    • 2 - (Recommended) If email already exist, replace it with the new one.
    • 3 - If email already exist, don't add the record.
  • MaxRecords: Maximum number of records that will be added to the NK2 file. It's recommended to set this value to the default of Outlook, which is 1000 for Outlook 2003, and 2000 to Outlook 2007/2010.
  • Weight Mode: Determines how to handle the Weight value and records order after the files are merged. You can specify one of the following values:
    • 0 - Don't change anything.
    • 1 - Set the Weight value of all records to 1 (initial value).
    • 2 - (Recommended) Sort the records according to the Weight value of the merged records.

Examples:

  • Merge file2.nk2 into file1.nk2 with maximum limitation of 2000 records.
    NK2Edit.exe /merge_files "f:\temp\file1.nk2" "" "f:\temp\file2.nk2" 2 2000 2
  • Merge the NK2 file of the default profile into merged.nk2, without records limitation (MaxRecords = 0). You can put this line in a logon script and create a large NK2 file which contains the NK2 records of all users...
    NK2Edit.exe /merge_files "z:\nk2data\merged.nk2" "" $default 2 0 2
  • Merge existing nk2 file with important records into the NK2 file of the default profile.
    NK2Edit.exe /merge_files $default "" "z:\records.nk2" 2 1000 2
  • Merge 1.nk2 into 2.nk2 and then save the result into 3.nk2
    NK2Edit.exe /merge_files "3.nk2" "2.nk2" "1.nk2" 2 1000 2
/ccenterfile <Filename> Specifies the Control Center information file (nk2info.dat) to load into the Control Center.
/ccenter Export the Control center table into a csv/html/xml file, without displaying any user interface. This parameter should be used with one of the export command-line option: /stext , /stab, /scomma , /stabular , /shtml , /sverhtml , /sxml
For example:
NK2Edit.exe /ccenter /shtml "c:\temp\ccenter.html"
NK2Edit.exe /ccenter /shtml "c:\temp\ccenter.html" /sort "Records Count"
NK2Edit.exe /ccenter /scomma "c:\temp\ccenter.csv" /sort "Records Count" /ccenterfile "f:\temp\nk2info.dat"

/open_control_center Opens the NK2 Control Center window, in addition to the main NK2 editor window.
/load_config <Filename> When you use this command-line option, NK2Edit will load the configuration from the specified filename, instead of using the default nk2edit.cfg located in the same folder of nk2edit.exe
When you exit from NK2Edit, the configuration will be saved to the same filename that you specified.

Example:
NK2Edit.exe /load_config "c:\myconfig\1.cfg"

/add_nk2_associate Associate the .nk2 extension with NK2Edit.
/remove_nk2_associate Remove the .nk2 association with NK2Edit.
/LogFile <Log Filename> This command-line option can be used with /script , /import_address_book , /export_to_contacts, /sync_address_book, /generate_new_nk2, /import_csv_file, and other command-line options. It creates a log file with information about any action made by NK2Edit and information about error occurred during the process.

Examples:
nk2edit.exe /logfile "import_address_book_log.txt" /import_address_book "contacts.nk2" "Contacts" "All" 2000
NK2Edit.exe /logfile "export_to_contacts_log.txt" /export_to_contacts $default
NK2Edit.exe /logfile "generate_new_nk2_log.txt" /generate_new_nk2 "generate_new.nk2" 500 500 1 0

/LogFileAppend <Log Filename> This command-line option is similar to the /LogFile command-line option. As opposed to the /LogFile command-line option that overwrites the log file if it already exists, this command-line options appends the new log lines to the end of the existing file.

Examples:
nk2edit.exe /LogFileAppend "import_address_book_log.txt" /import_address_book "contacts.nk2" "Contacts" "All" 1000
NK2Edit.exe /LogFileAppend "export_to_contacts_log.txt" /export_to_contacts $default
NK2Edit.exe /LogFileAppend "generate_new_nk2_log.txt" /generate_new_nk2 "generate_new.nk2" 200 200 1 0

/CurrDirExe Changes the current directory used for all other command-line options.
By default, when you specify a filename without a path (For example: NK2Edit.exe /script "myscript.txt" $default ""), NK2Edit searches the file in the current directory returned by Windows operating system. In most cases, the current directory is where the .exe file of NK2Edit is located, but in some other cases (For example, when running NK2Edit from RunOnce Registry key), the current directory might be different.
If /CurrDirExe is specified, NK2Edit will search the file in the same folder where NK2Edit.exe is located, even if the current directory of Windows operating system is different.

Example:
nk2edit.exe /CurrDirExe /script "myscript.txt" $default ""

In the above example, myscript.txt will be loaded from the folder of nk2edit.exe, even if the current directory of Windows points to another location.

/stext <Filename> Export the list of all AutoComplete entries into a simple text file.
/stab <Filename> Export the list of all AutoComplete entries into a tab-delimited text file.
/scomma <Filename> Export the list of all AutoComplete entries into a comma-delimited text file.
/stabular <Filename> Export the list of all AutoComplete entries into a tabular text file.
/shtml <Filename> Export the list of all AutoComplete entries into HTML file (Horizontal).
/sverhtml <Filename> Export the list of all AutoComplete entries into HTML file (Vertical).
/sxml <Filename> Export the list of all AutoComplete entries to XML file.
/soutlook <Filename> Export the list of all AutoComplete entries into a tab-delimited text file that can be used to import the emails/names list into the contacts of Outlook.
/ssimplecsv <Filename> Export the list of all AutoComplete entries into a simple comma-delimited file (csv) containing only the display name, email address, and address type. You can use the created file with 'Add Records From Simple csv File' option to import the addresses into another NK2 file.
/sort <column> This command-line option can be used with other save options for sorting by the desired column. If you don't specify this option, the list is sorted according to the last sort that you made from the user interface. The <column> parameter can specify the column index (0 for the first column, 1 for the second column, and so on) or the name of the column, like "Email" and "Display Name". You can specify the '~' prefix character (e.g: "~Display Name") if you want to sort in descending order. You can put multiple /sort in the command-line if you want to sort by multiple columns.

Examples:
nk2edit.exe /shtml "f:\temp\nk2.html" /sort 2 /sort ~1
nk2edit.exe /shtml "f:\temp\nk2.html" /sort "~Type" /sort "Email"

/nosort When you specify this command-line option, the list will be saved without any sorting.

More Command-Line Options

The following command-line options can be used to override the configuration loaded from the nk2edit.cfg file:
/AutoBackupOnFirstSave <0 | 1> Automatically Backup On First Save. 0 = No, 1 = Yes.
/OverwriteQuestion <0 | 1> Overwrite Question Before Every Save. 0 = No, 1 = Yes.
/DeleteQuestion <0 | 1> Ask Before Any Delete. 0 = No, 1 = Yes.
/DiscardChangesQuestion <0 | 1> Ask Before Discard Changes. 0 = No, 1 = Yes.
/ShowErrorMessagesOnOpen <0 | 1> Error Messages On File Open. 0 = No, 1 = Yes.
/AddExportHeaderLine <0 | 1> Add Header Line To CSV/Tab-Delimited File. 0 = No, 1 = Yes.
/UseAddressBookDefaultProfile <0 | 1> Use Address Book Of Default Profile. 0 = No, 1 = Yes.
/MarkDuplicateRecords <0 | 1> Mark Duplicate Records. 0 = No, 1 = Yes.
/UseSaveQuestion <0 | 1> Save Question Instead of Discard Question. 0 = No, 1 = Yes.
/EditMode <1 | 2> Edit Mode.

1 = Raw Text Edit Mode, 2 = Table Edit Mode

/MergeMode <1 | 2 | 3> Merge Mode.

1 = Always Add New Records, 2 = If Email Exists - Overwrite, 3 = If Email Exists - Don't Add.

/ExportCharEncoding <0 | 1 | 2 | 3> Specifies the characters encoding that will be used in the following export command-line options: /scomma , /stext , /shtml , /sverhtml , /sxml , /stab , /stabular , /soutlook , /ssimplecsv

0 = Default, 1 = UTF-8, 2 = UTF-16, 3 = Ascii

Return to NK2Edit introduction page