4 Replies Latest reply on Jun 1, 2016 12:40 PM by pogman

    batch install failing becasue of spaces in path name

    pogman

      Hello,

      I am having problems with vx1.2 batch install failing because of spaces in path for MIPPATH, has anyone had this issues and been able to get around it? it worked for install in v7.9.3 but can't get it to work now.

       

      SET MIPPATH="\\hrc.corp\dfssin\data\common\Engineering\Software Tools\Mentor Graphics\Software\VX1.2\design_capture_vx1.2\32bit\setup.exe"

       

      any suggestions would be appreciated.

       

      Thanks

        • 1. Re: batch install failing becasue of spaces in path name
          andrew_audova

          Hello,

           

          This looks like a possible batch tool defect. Usually the pushd "%~dp0" does the trick (maps the drive temporarily and cds to it) for UNC/network paths - which is part of the batch script code - but UNC + folders with spaces = a more complicated scenario

           

          I was able to reproduce the issue in-house, and the following seems to work for me (assumes the setup.exe is in the same folder as the batch script)

           

          If you want to give it a try, copy the following text to the top of the script (right below the @echo off) line. For other changes see the highlights in the screen-shots and the code snippets further below.

           

          :Get the current folder

          set CURRENTDIR=%~dp0

           

          :Remove the trailing slash (causes "net use" to fail)

          IF %CURRENTDIR:~-1%==\ SET CURRENTDIR=%CURRENTDIR:~0,-1%

           

          :Map folder (not peristent) to first available letter. Normally pushd would be used but it maps to the first

          :folder in the path and subsequent folders also have spaces so it won't resolve the problem

          net use * "%CURRENTDIR%" /persistent:no

           

          :Find which drive letter the mapping is under

          for /f "tokens=2" %%a in ('net use ^| find "%CURRENTDIR%"') do set TEMPMAP=%%a

          echo %TEMPMAP% has been mapped to "%CURRENTDIR%"

           

          Top half of script:

           

          Code snippets:

           

          PUSHD "%TEMPMAP%\"

          SET MIPPATH=%CD%setup.exe

          VER | FINDSTR /IL "6." > NUL

          IF %ERRORLEVEL% NEQ 0 SET MIPPATH=%CD%setup.exe

          echo MIPPATH is set to %MIPPATH%

           

          SET Self=%CD%%~n0%~x0

          REM SET Self=%~f0

          REM PUSHD "%~dp0"

           

           

          Bottom half of script:

           

          Code snippets:

           

          :Remove the temporary drive mapping (although a reboot will also clear it since it is not persistent)

          :Place this at or near the bottom of the batch script

          net use %TEMPMAP% /DELETE /YES

          • 2. Re: batch install failing becasue of spaces in path name
            pogman

            Hello Andrew,

             

            Thanks for the suggestion, I don't have much experience with bat files so excuse my lack of knowledge.

            I updated my bat file  and copied it to the same location as the setup.exe. When I started the bat file I received the following error.

             

            I already have V: mapped  and that is how I browse to the location of the batch file to start it. Not sure if that is the reason the MIPPATH is being set to C:\setup.exe

            Below is the batch file

            • 3. Re: batch install failing becasue of spaces in path name
              andrew_audova

              Yes, that would be why it failed. Sorry about that!

              A couple of changes that should hopefully get it working:

              1) Comment or remove the "PUSHD "%~dp0" line directly above the ":LOOP" line.

              2) Remove the new code that you added to the top (below the "@ echo off" and above the "set LC_ALL=en_US") and paste in the following updated code. This should work regardless of whether or not the drive is mapped. If the drive is mapped it will determine the UNC path and temporarily map a new drive (first letter available) to the level of the batch script in order to avoid the spaces in the path.

               

              Hopefully this works better!

               

              Cheers,

              Andrew

               

               

              :Get the current folder

              set CURRENTDIR=%~dp0

               

              :Have TEMPMAP default to current folder for when the drive is already mapped

              :set TEMPMAP=%CURRENTDIR%

               

              SET FIRSTTWO=%CURRENTDIR:~0,2%

              SET THEREST=%CURRENTDIR:~2%

              echo First two characters are "%FIRSTTWO%" and the rest of the path is "%THEREST%"

               

              IF %FIRSTTWO%==\\ GOTO mapdrive

              echo Drive is already mapped, now to find the UNC path

               

              :Find the UNC path based on currently mapped drive letter

              for /f "tokens=3" %%b in ('net use ^| find "%FIRSTTWO%"') do set CURRENTDIR=%%b%THEREST%

               

              :mapdrive

               

              echo UNC path is "%CURRENTDIR%"

               

              :Remove the trailing slash (causes "net use" to fail)

              IF %CURRENTDIR:~-1%==\ SET CURRENTDIR=%CURRENTDIR:~0,-1%

               

              echo Will now map drive to UNC path of batch script folder (deepest level to avoid any spaces)

               

              :Map folder (not peristent) to first available letter. Normally pushd would be used but it maps to the first

              :folder in the path and subsequent folders also have spaces so it won't resolve the problem

              net use * "%CURRENTDIR%" /persistent:no

               

              :Find which drive letter the new/temporary mapping is under

              for /f "tokens=2" %%a in ('net use ^| find "%CURRENTDIR%"') do set TEMPMAP=%%a

              echo %TEMPMAP% has been mapped to "%CURRENTDIR%"

              • 4. Re: batch install failing becasue of spaces in path name
                pogman

                Hello Andrew,

                     I updated the batch file with the code above but I am still getting the following error.

                I am working with our IT dept and looking at the possibility of just adding an _ to the directories that have a space, hopefully that will resolve the issue. I appreciate your help with this.