Path in .mnv file is missing backslashes

Document ID : KB000004788
Last Modified Date : 14/02/2018
Show Technical Document Details
Issue:
  • Running a dms script to collect path information and write this to a .mif file works fine but when the .mif is read by asset management agent and written to .mnv all the backslashes "\" are removed
  • for example the follwing dms script collects the path of the variable sdroot and writes it to a .mif

    Dim BaseSDPath as String
    Dim sMifFile AS String

    'Obtain %SDROOT% path 
    BaseSDPath=EnvGetString("SDROOT")

    sMifFile= ComputerPath + "sdroot.mif"

    CreateMIFFile(sMifFile,"Base SD install Path","This MIf file contains the base sd install Path (SDROOT)")
    CreateMIFGroup(sMifFile,"SDROOT","Base SD install Path","SD|path|1")
    CreateMIFString(sMifFile,"SDROOT","SDROOT",BaseSDPath,"Base SD install Path(%sdroot%)")

  • The path is shown correctly in the sdroot.mif but in the sdroot.mnv the \'s are missing

    000101[Base SD install Path]
    000201[Base SD install Path|SDROOT]
    00010500SDROOT|C:Program Files (x86)CADSMSD
Cause:
  • The international standard for mif files means that special characters need to be escaped with a \. so if you need the path to display a single \ it needs to be \\ in the mif file. 

  • The first \ escapes the special character allowing the second to display in the .mnv file.
Resolution:
  • We can add a function (here called DoubleSlash)  to the DMS that will replace \ with \\.
  • This will escape the special character and allow the additional inventory to be correctly reported

    Dim BaseSDPath as String
    Dim sMifFile AS String

    FUNCTION DoubleSlash(sString AS STRING) AS STRING
    DIM i as integer
    DIM sBuf as STRING
    sBuf=""
    FOR i=1 TO Len(sString)
       sBuf=sBuf+Mid(sString,i,1)  
       IF Mid(sString,i,1)="\" THEN
         sBuf=sBuf+"\"
      END IF
    NEXT i

    DoubleSlash=sBuf

    END FUNCTION

    'Obtain %SDROOT% path
    BaseSDPath=DoubleSlash(EnvGetString("SDROOT"))

    sMifFile= ComputerPath + "sdroot.mif"

    CreateMIFFile(sMifFile,"Base SD install Path","This MIf file contains the base sd install Path (SDROOT)")
    CreateMIFGroup(sMifFile,"SDROOT","Base SD install Path","SD|path|1")
    CreateMIFString(sMifFile,"SDROOT","SDROOT",BaseSDPath,"Base SD install Path(%sdroot%)")

  • Now sdroot.mnv is correctly formatted

    000101[Base SD install Path]
    000201[Base SD install Path|SDROOT]
    00010500SDROOT|C:\Program Files (x86)\CA\DSM\SD