migrating from 6.2 to 2019

Issues related to label design (working with databases, data processing, RFID encoding etc.) and printing (from NiceLabel Express, NiceLabel Pro, NiceForm and NicePrint)

Moderators: Georges, milos, NiceLabel Support Team

Post Reply
Posts: 7
Joined: Mon May 05, 2014 11:14 am

migrating from 6.2 to 2019

Post by Spikenaylor » Mon Oct 21, 2019 3:26 pm

What is the best way to go ahead with this

I have the 2019 trial

am getting loads of script errors and invalid date formatting errors.

in the 6.2 version had scripts from the website for printer status.

is there any tutorials for migrating from 6.2 to 2019 and can I use the scripts or where are the updated scripts

many thanks for any help

Code: Select all

Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
tempFolder = fso.GetSpecialFolder(2)
SettingsFile = tempFolder & "\" & ShortFormName & ".settings"
If (fso.FileExists(SettingsFile)) Then
  CanLoadSettings = "True"
  CanLoadSettings = "False"
End If
Process_Day = Date

Rem Printer Status

Rem Clear the printer status of the previously selected printer
PrinterStatus = ""
PrinterStatus_First = ""

Rem STEP 1: Get XML response from Label Services

Rem URL contains the path to the Label Services WebService interface
Rem Each computer with NiceLabel installed has Label Services, which listen on port 6758

Const URL = "http://localhost:6758/soap/PrintQueueSOAP"

Rem StatusFilename is the file into which we will save the response from the Label Services
Rem The file will contain XML message that we will parse for useful data

Const StatusFilename = "printerstatus.xml"

Rem strSoapReq is the WebService message (request) that we will send to the Label Services
Rem We are interested in the status for printer stored in the variable PrinterName
Rem Variable PrinterName gets value from the printer-selection combo box

strSoapReq = "<soapenv:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:epp=""EPPrintQueue"" xmlns:soapenc=""http://schemas.xmlsoap.org/soap/encoding/"">"
strSoapReq = strSoapReq & "   <soapenv:Header/>"
strSoapReq = strSoapReq & "   <soapenv:Body>"
strSoapReq = strSoapReq & "      <epp:GetSpecifiedPrinters soapenv:encodingStyle=""http://schemas.xmlsoap.org/soap/encoding/"">"
strSoapReq = strSoapReq & "         <APrinterNames xsi:type=""epp:TPrinterNames"" soapenc:arrayType=""xsd:string[]"">"
strSoapReq = strSoapReq & "            <i xsi:type='xsd:string'>" & PrinterName & "</i>"
strSoapReq = strSoapReq & "         </APrinterNames>"
strSoapReq = strSoapReq & "      </epp:GetSpecifiedPrinters>"
strSoapReq = strSoapReq & "   </soapenv:Body>"
strSoapReq = strSoapReq & "</soapenv:Envelope>"

Rem In this part we send the request to Label Services and store result (XML message) in a variable strResult
Rem Label Services supports several actions, in this case we use "GetSpecifiedPrinters", which will
Rem get all info for the provided printer (defined in variable PrinterName) 

Dim oHttp
Dim strResult
Set oHttp = CreateObject("Msxml2.XMLHTTP")
oHttp.open "POST", URL, false
oHttp.setRequestHeader "Content-Type", "text/xml"
oHttp.setRequestHeader "SOAPAction", "EPPrintQueue#GetSpecifiedPrinters"
oHttp.send strSoapReq
strResult = oHttp.responseText

Rem STEP 2: Write reponse from LabelServices to XML file in a user's temporary folder

Rem Write the XML message from Label Services into the user's %temp% folder
Rem We always use the same filename, as defined by variable StatusFilename
Rem We get the location of the %temp% folder from system variable 

Dim fso, tf

Set wshShell = CreateObject( "WScript.Shell" )
TempFolder = wshShell.ExpandEnvironmentStrings("%temp%") & "\"

Set fso = CreateObject("Scripting.FileSystemObject")
Set tf = fso.CreateTextFile(TempFolder & StatusFilename, True)
tf.Write strResult 

Rem STEP 3: Parse XML file

Rem A reponse from LabelServices is XML information about selected printer

Rem <?xml version="1.0"?>
Rem <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
Rem     <SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:NS2="EPPrintQueue">
Rem         <NS1:GetSpecifiedPrintersResponse xmlns:NS1="EPPrintQueue">
Rem             <return href="#1"/>
Rem         </NS1:GetSpecifiedPrintersResponse>
Rem         <NS2:TPQPrinterList id="1" xsi:type="NS2:TPQPrinterList">
Rem             <PrinterArray xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="NS2:TPQPrinter[1]">
Rem                 <item href="#2"/>
Rem             </PrinterArray>
Rem         </NS2:TPQPrinterList>
Rem         <NS2:TPQPrinter id="2" xsi:type="NS2:TPQPrinter">
Rem             <Attributes xsi:type="xsd:int">38</Attributes>
Rem             <DriverName xsi:type="xsd:string">ZEBRA RZ400 200DPI</DriverName>
Rem             <PrintJobList href="#3"/>
Rem             <Name xsi:type="xsd:string">ZEBRA RZ400 200DPI</Name>
Rem             <NiceStatus xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:string[2]">
Rem                 <item>Print head open</item>
Rem                 <item>Pause</item></NiceStatus>
Rem             <ShareName xsi:type="xsd:string">ZEBRA</ShareName>
Rem             <Status xsi:type="xsd:int">4</Status>
Rem             <HasWebBrowser xsi:type="xsd:boolean">true</HasWebBrowser>
Rem             <WebAddress xsi:type="xsd:string"></WebAddress>
Rem             <Updated xsi:type="xsd:boolean">true</Updated>
Rem             <NiceStatusEx xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:string[0]"/>
Rem         </NS2:TPQPrinter>
Rem         <NS2:PrintJobList id="3" xsi:type="NS2:TPQPrintJobList">
Rem             <PrintJobArray xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="NS2:TPQPrintJob[0]"/>
Rem         </NS2:PrintJobList>
Rem     </SOAP-ENV:Body>
Rem </SOAP-ENV:Envelope>

Rem Find the NS2:TPQPrinter node and parse information from it
Rem Note that counting of nodes starts with 0, not 1

Set objXMLDoc = CreateObject("Microsoft.XMLDOM") 
objXMLDoc.async = False 
objXMLDoc.load(TempFolder & StatusFilename) 

Rem Determine if the correct response was received by Label Services
Rem If there is no node NS2:TPQPrinter, then the printer status is not returned
Rem This will happen for network printers
Rem Label Services expects the printer driver to be installed locally

if objXMLDoc.getElementsByTagName("NS2:TPQPrinter").length > 0 then

Rem The node NS2:TPQPrinter exists, we have locally installed driver

    Set NodeList = objXMLDoc.getElementsByTagName("NS2:TPQPrinter")

    Rem Flag for NiceDriver is a second bit in the 1st element <Attributes>
    isNiceDriver = ((NodeList(0).childnodes(0).text and 2) = 2)

    Rem See if the printer driver reports some status
    Rem If there is no status, we will not parse the status messages
    hasStatus = (NodeList(0).childnodes(4).text <> "")

    Rem Printer status is stored in the 5th element <NiceStatus>
    Rem The printer can be in many statuses at the same time
    Rem That's why we have to loop for all statues and combine them together
    Rem We only loop statuses if the variable hasStatus is True - not for non-NiceDrives and not for NiceDrivers that are not in error state

    if hasStatus then
    Rem Get all childnodes "item" from node "NiceStatus"
        Set NodeList = objXMLDoc.getElementsByTagName("NiceStatus/item")

        PrinterStatus_First = Nodelist(0).text

        for each itemNode in NodeList
            PrinterStatus = PrinterStatus & itemNode.childnodes(0).text & ", "

        Rem Remove the string ", " at the end
        PrinterStatus = Left(PrinterStatus, Len(PrinterStatus)-2)

    end if


Rem The node NS2:TPQPrinter does not exist, we don't have locally installed driver
Rem Printer status cannot be determined

    isNiceDriver = ""
    hasStatus = ""
    PrinterStatus = ""

end if

Set objXMLDoc = Nothing

Rem UI

Rem Images & Buttons: Bulbs and Pause

Rem The variable PrinterStatus contains the problematic printer states

Rem If there is no data for PrinterStatus and driver is NiceDriver, we set status to "Ready"
Rem If there is no data for PrinterStatus and driver is other Windows driver, we set status to "N/A".
Rem LabelServices cannot check statuses of printers that do not use NiceDrivers.  

Rem Some printers can report multiple simultaneous statuses, such as "Head open", "Pause"
Rem This form will always show details just for the first message

if PrinterStatus = "" then
    isPrinterError = false
    Select Case isNiceDriver
        Case "True" PrinterStatus = "Ready": PrinterStatus_First = "Ready"
        Case "False" PrinterStatus = "N/A": PrinterStatus_First = "N/A"
        Case "" PrinterStatus = "N/A": PrinterStatus_First = "N/A"
    End Select
    isPrinterError = true
end if

Rem Bulbs and Print Button

if isNiceDriver = "True" then
  txtNiceDriver = "THIS IS NICEDRIVER"
  if PrinterStatus = "Ready" then
    imgBulb = "btnTraffic Lights-green.png"
    imgPrint = "btnPrinter-green.png"
    imgBulb = "btnTraffic Lights-red.png"
    imgPrint = "btnPrinter-red.png"
  end if 
elseif isNiceDriver = "False" then
  imgBulb = "btnTraffic Lights-yellow.png"
  imgPrint = "btnPrinter-yellow.png"
  imgBulb = "btnTraffic Lights-yellow.png"
  imgPrint = "btnPrinter-yellow.png"
end if

Rem Image for Error Detail
Rem The variable errActionID is used in onClick event on images with error detail
Rem For specific ID the specific action will execute
Rem In OnClick event all possible actions are defined, errActionID is used in the condition for every action 

Select Case PrinterStatus_First
  Case "Ready"                           errImg = "errReady.png":         errActionID = "0"
  Case "N/A"                             errImg = "errna.png":            errActionID = "1"
  Case "Out of ribbon"                   errImg = "errOutofRibbon.png":   errActionID = "3"
  Case "Ribbon Missing"                  errImg = "errOutofRibbon.png":   errActionID = "3"
  Case "Ribbon Out"                      errImg = "errOutofRibbon.png":   errActionID = "3"
  Case "Out of paper"                    errImg = "errOutofLabels.png":   errActionID = "4"
  Case "Out Of Paper"                    errImg = "errOutofLabels.png":   errActionID = "4"
  Case "Out of paper and/or ribbon"      errImg = "errOutofLabels.png":   errActionID = "5"
  Case "Out of labels"                   errImg = "errOutofLabels.png":   errActionID = "6"
  Case "Media Out"                       errImg = "errOutofLabels.png":   errActionID = "6"
  Case "Media error"                     errImg = "errOutofLabels.png":   errActionID = "6"
  Case "Print head open"                 errImg = "errHeadOpen.png":      errActionID = "7"
  Case "Print head error"                errImg = "errHeadOpen.png":      errActionID = "8"
  Case "Head Open"                       errImg = "errHeadOpen.png":      errActionID = "7"
  Case "Head Opened"                     errImg = "errHeadOpen.png":      errActionID = "7"
  Case "Port conflict"                   errImg = "errPortConflict.png":  errActionID = "9"
  Case "Not accessible"                  errImg = "errNotAccessible.png": errActionID = "1"
  Case "Pause"                           errImg = "errPause.png":         errActionID = "2"
  Case "Paused"                          errImg = "errPause.png":         errActionID = "2"
  Case "Standby - Pause"                 errImg = "errPause.png":         errActionID = "2"
  Case else                              errImg = "errOther.png":         errActionID = ""
End Select

Error2.jpg (44.37 KiB) Viewed 1066 times
Error1.jpg (44.48 KiB) Viewed 1066 times

User avatar
NiceLabel Support
NiceLabel Support
Posts: 135
Joined: Fri Jul 13, 2018 10:26 pm
Location: Milwaukee, Wisconsin

Re: migrating from 6.2 to 2019

Post by Mytch » Mon Oct 21, 2019 5:17 pm


We are not going to have any tutorials for converting scripts from NiceLabel 6 to NiceLabel 2019. Although, we do have an article here discussing the differences between versions:
https://www.nicelabel.com/support/knowl ... icelabel-6

Your first error is simply an issue with input formatting. You can change the input rules of "Process_Day" to allow the expected date format, which appears to be dd/MM/yyyy instead of dd MMM yyy.

Your second error, regarding a resource not being found, is due to methods trying to get printer info/status from "Label Services", which is no longer used in NiceLabel 2019. The logic of getting printer settings and status should be done through supported methods allowed in NiceLabel 2019. There is no expectation that this script is capable of being "converted", but rather should be re-implemented in a new manner. For instance, we offer a native Action called "Printer Status", which can be used to retrieve similar data from a defined printer driver.


Post Reply