Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: white spaces in path while using start command  (Read 10272 times)

0 Members and 1 Guest are viewing this topic.

Grimbear13

    Topic Starter


    Rookie

    white spaces in path while using start command
    « on: December 07, 2009, 09:49:26 AM »
    I'm trying to make a startup process at work.  I need it to open several programs in a certain order.  The problem I keep running into is white spaces in the directories or the folders I need opened.

    start C:\folder1\folder2\Folder To Be Opened

    It will either tell me that Folder does not exist there or it will open another folder that is just that first word.  Since I am at work and these are used by other processes I cannot just rename them.  Also I found that I could not use "" like in many other languages and batch processes because the start command automatically uses the "" to assign window title. 

    I attempted to use the /d command but that didn't seem to work as well as assigning the path to a variable to be called.  However when using variables I couldn't get it to run the path and not whatever the varaiable name was.

    set TM="Ticket Folder"

    start C:\fold1\fold2\TM
    cannot find TM

    start C:\fold1\fold2\%TM
    cannot find TM

    start C:\fold1\fold2\%%TM
    cannot find %TM

    I had previously run into issues with variables in for loops and the double % was the fix so I attempted here as well.

    Thank you in Advance for reading/assistance.

    nothlit



      Intermediate

      Thanked: 2
      Re: white spaces in path while using start command
      « Reply #1 on: December 07, 2009, 10:00:08 AM »
      To expand a variable you need to do

      Code: [Select]
      %tm%

      Have you tried
      Code: [Select]
      Start explorer C:\folder1\folder2\folder

      billrich



        Rookie

        Thanked: 1
        Re: white spaces in path while using start command
        « Reply #2 on: December 07, 2009, 10:23:19 AM »

        C:\batch>type  grimbear.bat
        Code: [Select]
        @echo off
        REM  TM below is variable and runs in RAM
        REM  C:\fold1\fold2\TM.  TM is a file stored on the HDD.
        REM Fold1 and fold2 are directories located on the HDD.

        cd \


        set TM="Ticket Folder"

        echo TM = %TM%

        cd \
        cd batch
        md fold1
        cd fold1
        md fold2
        cd fold2

        echo this a file called TM  > TM.txt

        type TM.txt

        dir *.*

        Output:

        C:\batch>grimbear.bat
        TM = "Ticket Folder"
        This a file called TM
         Volume in drive C has no label.
         Volume Serial Number is F4A3-D6B3

         Directory of C:\batch\fold1\fold2

        12/07/2009  11:18 AM    <DIR>          .
        12/07/2009  11:18 AM    <DIR>          ..
        12/07/2009  11:20 AM                25 TM.txt
                       1 File(s)             25 bytes
                       2 Dir(s)  305,553,166,336 bytes free

        C:\batch\fold1\fold2>

        gpl



          Apprentice
        • Thanked: 27
          Re: white spaces in path while using start command
          « Reply #3 on: December 07, 2009, 11:58:46 AM »
          Try
          Code: [Select]
          start "C:\fold1\fold2\%TM%"

          billrich



            Rookie

            Thanked: 1
            Re: white spaces in path while using start command
            « Reply #4 on: December 07, 2009, 12:39:59 PM »
            Try
            Code: [Select]
            start "C:\fold1\fold2\%TM%"

            Is  %TM%  a file or a variable?

            If TM is a file is the extention .txt . . . TM.txt?

            BC_Programmer


              Mastermind
            • Typing is no substitute for thinking.
            • Thanked: 1140
              • Yes
              • Yes
              • BC-Programming.com
            • Certifications: List
            • Computer: Specs
            • Experience: Beginner
            • OS: Windows 11
            Re: white spaces in path while using start command
            « Reply #5 on: December 07, 2009, 12:45:33 PM »
            Is  %TM%  a file or a variable?

            If TM is a file is the extention .txt . . . TM.txt?

            it's a variable, according to the first post:

            Quote
            set TM="Ticket Folder"

            the OP has tried %TM and %%TM but missed the proper method of accessing environment variables, which was to delimit both ends with percent signs %TM%.
            I was trying to dereference Null Pointers before it was cool.

            billrich



              Rookie

              Thanked: 1
              Re: white spaces in path while using start command
              « Reply #6 on: December 07, 2009, 01:19:17 PM »
              it's a variable, according to the first post:

              the OP has tried %TM and %%TM but missed the proper method of accessing environment variables, which was to delimit both ends with percent signs %TM%.

              Grimbear (OP ) cannot find the variable  TM  Or %TM%  on the hard disk drive:

              start C:\fold1\fold2\TM

              "cannot find TM"  (System Error )

              "cannot find %TM%"  (System Error )

              Helpmeh



                Guru

              • Roar.
              • Thanked: 123
                • Yes
                • Yes
              • Computer: Specs
              • Experience: Familiar
              • OS: Windows 8
              Re: white spaces in path while using start command
              « Reply #7 on: December 07, 2009, 01:28:36 PM »
              Grimbear (OP ) cannot find the variable  TM  Or %TM%  on the hard disk drive:

              start C:\fold1\fold2\TM

              "cannot find TM"  (System Error )

              "cannot find %TM%"  (System Error )

              Because %TM% already has quotes in it maybe? And on a different note, what happened to your post count? If you don't feel comfortable talking about it in public, you can send me a pm.
              Where's MagicSpeed?
              Quote from: 'matt'
              He's playing a game called IRL. Great graphics, *censored* gameplay.

              Salmon Trout

              • Guest
              Re: white spaces in path while using start command
              « Reply #8 on: December 07, 2009, 01:30:47 PM »

              Salmon Trout

              • Guest
              Re: white spaces in path while using start command
              « Reply #9 on: December 07, 2009, 01:34:45 PM »
              Also I found that I could not use "" like in many other languages and batch processes because the start command automatically uses the "" to assign window title. 

              Yes, it does, but you can still use them later on e.g.

              Code: [Select]
              start "" "C:\Program Files\Ahead DVD Ripper\Ahead DVD Ripper.exe"

              BC_Programmer


                Mastermind
              • Typing is no substitute for thinking.
              • Thanked: 1140
                • Yes
                • Yes
                • BC-Programming.com
              • Certifications: List
              • Computer: Specs
              • Experience: Beginner
              • OS: Windows 11
              Re: white spaces in path while using start command
              « Reply #10 on: December 07, 2009, 01:51:45 PM »
              Grimbear (OP ) cannot find the variable  TM  Or %TM%  on the hard disk drive:

              "cannot find %TM%"  (System Error )

              he never tried %TM%.
              I was trying to dereference Null Pointers before it was cool.

              Salmon Trout

              • Guest
              Re: white spaces in path while using start command
              « Reply #11 on: December 07, 2009, 01:54:00 PM »
              Nothing changes, does it?  ::)

              Helpmeh



                Guru

              • Roar.
              • Thanked: 123
                • Yes
                • Yes
              • Computer: Specs
              • Experience: Familiar
              • OS: Windows 8
              Where's MagicSpeed?
              Quote from: 'matt'
              He's playing a game called IRL. Great graphics, *censored* gameplay.

              BC_Programmer


                Mastermind
              • Typing is no substitute for thinking.
              • Thanked: 1140
                • Yes
                • Yes
                • BC-Programming.com
              • Certifications: List
              • Computer: Specs
              • Experience: Beginner
              • OS: Windows 11
              Re: white spaces in path while using start command
              « Reply #13 on: December 07, 2009, 02:04:08 PM »
              >:(

               ???

              Billrich was banned. That is why.
              I was trying to dereference Null Pointers before it was cool.

              billrich



                Rookie

                Thanked: 1
                Re: white spaces in path while using start command
                « Reply #14 on: December 07, 2009, 02:20:23 PM »
                he never tried %TM%.

                Variables can be found in RAM.  Files can be found on the Hard Disk Drive.

                echo Variable TM = %TM%

                A file TM  on the Hard Disk Drive is  found:

                type C:\folder1\folder2\TM.txt