none
Cmd file not running correctly from task bar RRS feed

  • Question

  • Hello

    I have a simple cmd file that creates folders in a specific shared drive based on prompts entered.  One of the folders created contains a number that is incremented each time it is run.

    It runs fine in win explorer , but when saved as a shortcut to the desktop to allow it to run from the task bar, it no longer will pick up the number. Below is the file:

    'create new folders

    SET initDir=G:\New_Folder
    SET newDir=
    SET /P newjob=Type Job name: %=%
    SET /P newDesc=Type Description name: %=%
    SET /P newLocat=Type Location: %=%

    cd "G:\Estimating Templates\"
    for /f %%x in (Count.txt) do (set /a var=%%x+1)
    >Count.txt echo %var%

    IF DEFINED newDir (md O:\"%newjob% - %newDesc% - %newLocat%"
     SET initDir=%initDir%\"%newjob% - %newDesc% - %newLocat%" )

       
         md O:\"%newjob% - %newDesc% - %newLocat%"\Bidders
          md O:\"%newjob% - %newDesc% - %newLocat%\~%var% "

           md O:\"%newjob% - %newDesc% - %newLocat%"\Close_Outs
           md O:\"%newjob% - %newDesc% - %newLocat%"\Drawings
            md O:\"%newjob% - %newDesc% - %newLocat%"\Drawings\"Original Drawings"
              md O:\"%newjob% - %newDesc% - %newLocat%"\Flooring
               md O:\"%newjob% - %newDesc% - %newLocat%"\"Forms and Exhibits"
                 md O:\"%newjob% - %newDesc% - %newLocat%"\Specs

        md O:\"%newjob% - %newDesc% - %newLocat%"\Submittals
         md O:\"%newjob% - %newDesc% - %newLocat%"\Submittals\Painting
         md O:\"%newjob% - %newDesc% - %newLocat%"\Submittals\Flooring
         md O:\"%newjob% - %newDesc% - %newLocat%"\Submittals\Ceramic
         md O:\"%newjob% - %newDesc% - %newLocat%"\Submittals\Resinous_Terrazzo

           

       %SystemRoot%\explorer.exe O:\"%newjob% - %newDesc% - %newLocat%"

    Thank you!

    Mary

    Wednesday, November 13, 2019 6:22 PM

All replies

  • Is count.txt in G:\Estimating Templates? 

    cd "G:\Estimating Templates\"    changes the current directory on the G: drive, but it does not set the current drive to G:.

    Just add a G: statement. 

    G:
    cd "G:\Estimating Templates\"
    for /f %%x in (Count.txt) do (set /a var=%%x+1)
    >Count.txt echo %var%
     


     


    • Edited by MotoX80 Wednesday, November 13, 2019 9:24 PM
    Wednesday, November 13, 2019 9:23 PM
  • Hi, 

    According to your description, we recommend to ask for help from Script forum. They should be more familiar with your issue and should have more resource to help you. 

    Bests, 


    Please remember to mark the replies as answers if they help. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Thursday, November 14, 2019 8:54 AM
    Moderator