Creating Barcodes with the Console, Command Prompt or Shell Scripts

ConnectCode Barcode Fonts pack provides an advance application, BarcodeCommand, for creating barcodes in the console (Command Prompt or Command-Line Interface Tool). This application accepts inputs such as data to be encoded and barcode symbology as command line parameters. With this capability, external or third party tools can easily create professional barcodes by executing the console application. Users will also be able to integrate the barcode generation process into their enterprise workflow processes.

By allowing barcodes to be generated using a console application also offers several other advantages. For example, scripts can be created to generate barcodes with a running number to tag products at item level. The product numbers can also be specified in a text file for the console application to create barcodes in bulk.

In general, BarcodeCommand performs several tasks such as the validation of input data, generation of start/stop characters, creation of check digits and generation of a output string (to be used together with barcode fonts) to create barcodes.



When a barcode created using a font is printed, it rasters to the resolution of the printer and will not be limited to the DPI (Dots per Inch) of an image. This allows resolution-independent barcodes that meet the strictest industry requirements to be created.

Details of the Console application

  • Directory : <ConnectCode Barcode Fonts Directory>\Resource\Command Prompt
  • Application Name : BarcodeCommand.exe

An overview of using BarcodeCommand for creating barcodes

The command below can be entered in the Command Prompt ("command.exe" tool ) of Windows to generate a Code39 barcode. The input parameter "901234567" is the data to be encoded as the barcode and the parameter "1" indicates a check digit generation.


BarcodeCommand Code39 "901234567" 1


The output string generated by the above command is shown below. By applying a barcode font on this string, a barcode that adheres to industry specifications can be created. The next section provides a complete step-by-step tutorial of using BarcodeCommand and the text editor Wordpad to create barcodes.


*901234567.*


Step-by-step Tutorial

  • Launch the Command Prompt shell in Windows. Simply go to the Start Menu and enter "command" in the search bar. Windows will launch the console as shown in the diagram below.



  • Change the directory to where BarcodeCommand is located. For example, "cd C:\Program Files\ConnectCode\Resource\Command Prompt". BarcodeCommand is located in the "Resource\Command Prompt" subdirectory of ConnectCode Barcode Fonts.
  • Enter the following command 'BarcodeCommand Code39 "901234567" 1 > %HOMEPATH%\barcodefile.txt' and press the enter key. This command generates a Code39 barcode and redirects the output to a text file named "barcodefile.txt" located in the user home directory. Please note that saving a file to the program directory is denied by Windows for security reasons.
  • After executing the command, open "barcodefile.txt" using Wordpad. You can enter %HOMEPATH% in Windows Explorer to quickly locate the file.
  • Select the contents "*01234567892*", change the font to "CCode39_S3" and set the font size to "24".

A barcode that meets all the different industry specifications has been created. The complete list of commands and fonts to be applied to create different types of barcodes is described in the Help File.

Creating barcodes with a running number

This tutorial illustrates how to create barcodes with a running number. For example, a series of barcode can be encoded with the numbers ranging from 12345670 to 12345678. Creating such barcodes is useful when each individual product items in the corporation needs to be tracked and monitored. This tutorial uses the BarcodeCommand console application and Windows Shell Scripts to demonstrate how such barcodes can be created easily.

  • Launch the Command Prompt shell in Windows. Simply go to the Start Menu and enter "command" in the search bar. Windows will launch the console as shown in the diagram below.


  • Change the directory to where BarcodeCommand is located. For example, "cd C:\Program Files\ConnectCode\Resource\Command Prompt". By default, BarcodeCommand is located in the "Resource\Command Prompt" subdirectory of ConnectCode Barcode Fonts.
  • A sample script "VariableData.cmd" is already created to illustrate how this can be done. The content of this script is as follows:


    ECHO OFF
    FOR /L %%G IN (12345670,1,12345678) DO BarcodeCommand Code39 %%G 1 >> %HOMEPATH%\outputfile.txt


    The script loops from the number "12345670" to "12345678" and uses this as an input data to create Code39 barcodes. The parameter "1" indicates check digit generation. The output of the command is redirected to the file "outputfile.txt" located in the user home directory. Please note that saving a file to the program directory is denied by Windows for security reasons.
  • Execute the script by entering "VariableData" in the Commmand Prompt and pressing the enter key.
  • Go to the Start Menu and launch Accessories -> Wordpad.
  • Use Wordpad to open the "outputfile.txt" file in the user home directory. The contents of the file is shown below.


    *12345670S*
    *12345671T*
    *12345672U*
    *12345673V*
    *12345674W*
    *12345675X*
    *12345676Y*
    *12345677Z*
    *12345678-*


  • Change the content of the file as follows: the font to "CCode39_S3" and font size to "24". A list of barcodes with a running number is created.



Creating barcodes with data stored in a text file

This tutorial illustrates how to create barcodes with data stored in a text file using BarcodeCommand and Windows Shell scripts. Imagine the scenario where a text file stores a list of product item numbers exported from the company's Enterprise System or Reporting Application. Each of the product item numbers needs to be generated as a barcode for tagging the actual item. An example of such a text file is shown below.

912345670
912345671
912345672
912345673
912345674
912345675
912345676
912345677
912345678

  • To create barcodes from a text file, simply follow the steps shown below.
  • Launch the Command Prompt shell in Windows. Simply go to the Start Menu and enter "command" in the search bar. Windows will launch the console as shown in the diagram below.



  • Change the directory to where BarcodeCommand is located. For example, "cd C:\Program Files\ConnectCode\Resource\Command Prompt". By default, BarcodeCommand is located in the "Resource\Command Prompt" subdirectory of ConnectCode Barcode Fonts.
  • A sample script "VariableDataFile.cmd" is already created to illustrate how this can be done. The content of this script is as follows:


    ECHO OFF
    FOR /F "tokens=1" %%G IN (barcodedata.txt) DO BarcodeCommand Code39 %%G 1 >> %HOMEPATH%\"outputfiledata.txt"


    The script reads the contents of the "barcodedata.txt" file and uses it as input data to create Code39 barcodes. The parameter "1" indicates check digit generation. The output of the command is redirected to the file "outputfiledata.txt" located in the user home directory. Please note that saving a file to the program directory is denied by Windows for security reasons.
  • Execute the script by entering "VariableDataFile" in the Commmand Prompt and pressing the enter key.
  • Go to the Start Menu and lauch Accessories -> Wordpad.
  • Use Wordpad to open "outputfile.txt" located in the user home directory. The content of the file is as follows:


    *912345670.*
    *912345671 *
    *912345672$*
    *912345673/*
    *912345674+*
    *912345675%*
    *9123456760*
    *9123456771*
    *9123456782*


  • Change the content of the file as follows: the font to "CCode39_S3" and font size to "24". A list of barcodes with the above input data is created.