.bat file yields "the system cannot find the path specified" error

la_colibri
la_colibri used Ask the Experts™
on
Would greatly appreciate assistance with this issue I am having with a batch file.....

I run the batch script below with the goal in mind of executing three other batch files in three different locations all at once... even though I verified the locations I entered in the script is correct I am getting the error "the system cannot find the path specified for all three. Please advise... thanks!



@ECHO This script runs all the batch files to deploy 4.1 builds
@ECHO Do you want to continue?
@ECHO OFF
PAUSE

goto START


REM ***********************************************************************************
REM  Batch file for Build Deployments (4.1.1.6603, 4.1.1.6659, 4.1.1.6712, 4.1.1.6751)
REM
REM  Version 1.0 By LMS As Of: 10:18 AM 07/01/2010
REM ***********************************************************************************


:START

@ECHO Running batch files for 4.1 builds . . .


@ECHO . . . Build 4.1.1.6603
cd..
cd Build 4.1.1.6603
START /b /wait C:\Projects\Build 4.1.1.6603\[4.1.1.6603]Run_Build_Scripts.bat
cd..


@ECHO . . . Build 4.1.1.6659
cd Build 4.1.1.6659
START /b /wait C:\Projects\Build 4.1.1.6659\[4.1.1.6659]Run_Build_Scripts.bat
cd..


@ECHO . . . Build 4.1.1.6712
cd Build 4.1.1.6712
START /b /wait C:\Projects\Build 4.1.1.6712\[4.1.1.6712]Run_Build_Scripts.bat
cd..


@ECHO . . . Build 4.1.1.6751
cd Build 4.1.1.6751
START /b /wait C:\Projects\Build 4.1.1.6751\[4.1.1.6751]Run_Build_Scripts.bat
cd..




@ECHO Done

goto END

:END
exit
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Assistant Vice President\Network Manager
Commented:
You need to place quotes on the the "start" lines due to spaces

START /b /wait C:\Projects\Build 4.1.1.6603\[4.1.1.6603]Run_Build_Scripts.bat

should be

START /b /wait "C:\Projects\Build 4.1.1.6603\[4.1.1.6603]Run_Build_Scripts.bat"

Commented:
Put "" around the paths:

@ECHO . . . Build 4.1.1.6751
cd "Build 4.1.1.6751"
START "Title" /b /wait "C:\Projects\Build 4.1.1.6751\[4.1.1.6751]Run_Build_Scripts.bat"
cd..
being careful with the START command since the first paramter in quotes is the window title so add a dummy (or real) title should it:

Steve
Try this:
 
@ECHO This script runs all the batch files to deploy 4.1 builds
@ECHO Do you want to continue?
@ECHO OFF
PAUSE

goto START


REM ***********************************************************************************
REM  Batch file for Build Deployments (4.1.1.6603, 4.1.1.6659, 4.1.1.6712, 4.1.1.6751)
REM
REM  Version 1.0 By LMS As Of: 10:18 AM 07/01/2010
REM ***********************************************************************************


:START

@ECHO Running batch files for 4.1 builds . . .


@ECHO . . . Build 4.1.1.6603
cd..
cd Build 4.1.1.6603
START /b /wait "C:\Projects\Build 4.1.1.6603\[4.1.1.6603]Run_Build_Scripts.bat"
cd..


@ECHO . . . Build 4.1.1.6659
cd Build 4.1.1.6659
START /b /wait "C:\Projects\Build 4.1.1.6659\[4.1.1.6659]Run_Build_Scripts.bat"
cd..


@ECHO . . . Build 4.1.1.6712
cd Build 4.1.1.6712
START /b /wait "C:\Projects\Build 4.1.1.6712\[4.1.1.6712]Run_Build_Scripts.bat"
cd..


@ECHO . . . Build 4.1.1.6751
cd Build 4.1.1.6751
START /b /wait "C:\Projects\Build 4.1.1.6751\[4.1.1.6751]Run_Build_Scripts.bat"
cd..




@ECHO Done

goto END

:END
exit  
How to Generate Services Revenue the Easiest Way

This Tuesday! Learn key insights about modern cyber protection services & gain practical strategies to skyrocket business:

- What it takes to build a cloud service portfolio
- How to determine which services will help your unique business grow
- Various use-cases and examples

Commented:
Cross posted there but pony10us version won't work because of the mentione title parameter (though that is technicality wih START command only, " " in general is what is needed as was said)

Commented:
Likewise TheQuietShadow.... no " " around CD and no Title parameter :-)
Steven CarnahanAssistant Vice President\Network Manager

Commented:
Steve,

Thank you, I missed that there was not "Title" in the line.

Author

Commented:
So to confirm my script should look like the following?

@ECHO This script runs all the batch files to deploy 4.1 builds
@ECHO Do you want to continue?
@ECHO OFF
PAUSE

goto START


REM ***********************************************************************************
REM  Batch file for Build Deployments (4.1.1.6603, 4.1.1.6659, 4.1.1.6712, 4.1.1.6751)
REM
REM  Version 1.0 By LMS As Of: 10:18 AM 07/01/2010
REM ***********************************************************************************


:START

@ECHO Running batch files for 4.1 builds . . .


@ECHO . . . Build 4.1.1.6603
cd..
cd "Build 4.1.1.6603"
START "Title" /b /wait "C:\Projects\Build 4.1.1.6603\[4.1.1.6603]Run_Build_Scripts.bat"
cd..


@ECHO . . . Build 4.1.1.6659
cd "Build 4.1.1.6659"
START "Title" /b /wait "C:\Projects\Build 4.1.1.6659\[4.1.1.6659]Run_Build_Scripts.bat"
cd..


@ECHO . . . Build 4.1.1.6712
cd "Build 4.1.1.6712"
START "Title" /b /wait "C:\Projects\Build 4.1.1.6712\[4.1.1.6712]Run_Build_Scripts.bat"
cd..


@ECHO . . . Build 4.1.1.6751
cd "Build 4.1.1.6751"
START "Title" /b /wait "C:\Projects\Build 4.1.1.6751\[4.1.1.6751]Run_Build_Scripts.bat"
cd..




@ECHO Done

goto END

:END
exit
Steven CarnahanAssistant Vice President\Network Manager

Commented:
Yes that looks correct.
Ben Personick (Previously QCubed)Lead SaaS Infrastructure Engineer

Commented:
You need to encapsulate all directories with double quotes.  That is why your script cannot find them.  I will also simplify this script for you and post again.


Author

Commented:
it's still giving me that same error but goes farther than before.... output states "file not found' after I 'press the key to continue' when prompted... I checked the database to validate but the updates were not made so it's still not executing as it should...


Microsoft Windows [Version 6.0.6001]
Copyright (c) 2006 Microsoft Corporation.  All rights reserved.

C:\Users\Administrator>cd C:\Projects

C:\Projects>Run_All_4.1Builds.bat [database_name]
This script runs all the batch files to deploy 4.1 builds
Do you want to continue?
Press any key to continue . . .
Running batch files for 4.1 builds . . .
. . . Build 4.1.1.6603
The system cannot find the path specified.
****************************************************************************
 Batch file for [database_name] 4.1.1.6603 - Build 4.1.1.6603
 Build Date: 2/12/2010
****************************************************************************
Adding scripts to emass database for [database_name] Version 4.1.1.6603  Build 4.1.1.6603
Do you want to continue?
Press any key to continue . . .
[PERFORMING PRIORITY TASKS]:
File Not Found
[UPDATING SCHEMA]:
File Not Found
[UPDATING DATA]:
File Not Found
[ADDING NEW PROCEDURES/FUNCTIONS]:
File Not Found
[UPDATING PROCEDURES/FUNCTIONS]:
File Not Found
[ADDING NEW VIEWS]:
File Not Found
[UPDATING VIEWS]:
File Not Found
[PERFORMING CLEANUP TASKS]:
File Not Found
[SETTING PERMISSIONS]:
Cannot open input file - SET_PERMISSIONS.sql
No such file or directory
All scripts completed.
Please refer to the log files to validate successful runs.
Press any key to continue . . .
Steven CarnahanAssistant Vice President\Network Manager

Commented:
Where are you excuting this from? Let me comment each line to see if it is doing what you think it is.

@ECHO . . . Build 4.1.1.6603

REM change up one level in the driectory structure from where you are currently.
REM ***You may want to change thiis to specificy what directly you want to start in***
cd..

REM change down one level in the directory structure to "Build 4.1.1.6603"
REM good if it actuall exists depending on where you started from
cd "Build 4.1.1.6603"

REM Run another batch file (unknown contents)  using START command/switchts
START "Title" /b /wait "C:\Projects\Build 4.1.1.6603\[4.1.1.6603]Run_Build_Scripts.bat"

REM change back up one level in the directory structure
cd..
Ben Personick (Previously QCubed)Lead SaaS Infrastructure Engineer

Commented:
Here I think you will like this script very much.

::------------------------------------------------------------------------------------------------::
:: Script: DeployBuilds.Bat                                            				 			  ::
:: Version: 1.0                                                                                   ::
:: Copyright: Ben Personick                                                                       ::
:: Date: 2010-07-06                                                                               ::
::                                                                                                ::
::                                                                                                ::
:: Desc: This script runs all the batch files to deploy 4.1 builds								  ::
::   - Batch file for Build Deployments (4.1.1.6603, 4.1.1.6659, 4.1.1.6712, 4.1.1.6751)		  ::
::																								  ::
::  Based on: Version 1.0 By LMS As Of: 10:18 AM 07/01/2010                                       ::
::------------------------------------------------------------------------------------------------::
:Begin
@ECHO OFF

::------------------------------------------------------------------------------------------------::
:: This section sets up default variable settings and sets the logging directory and file name.   ::
::------------------------------------------------------------------------------------------------::
:Start-Prep
	SET TDate=%date:~10,4%-%date:~4,2%-%date:~7,2%
	SET TTime=%Time:~0,2%.%Time:~3,2%.%Time:~6,2%
	SET Preamble=DeployBuilds --
	SET SourceDir=C:\Projects
	SET IDir=c:\DeployBuilds\Log
	SET ILog=ILog_%TDate%_%TTime%.Log
	:Start-IDir
		ECHO %Preamble% Checking For %IDir%
		IF EXIST %IDir% ECHO %Preamble% IDir "%IDir%" -- Found! -- GOTO End-Prep >> %IDir%\%ILog%
		IF EXIST %IDir% GOTO End-IDir
		ECHO %Preamble% Creating %IDir%
		mkdir %IDir%
	:End-IDir

:End-Prep

::------------------------------------------------------------------------------------------------::
:: This Menu allows you to choose to continue or exit the installation						      ::
::------------------------------------------------------------------------------------------------::
:Start-Menu
echo This script runs all the batch files to deploy 4.1 builds
echo Please choose an option:
echo [A] Install Now
echo [B] Quit
::START-CHOICE::
:Start-Choice
SET /P C=[A,B]? 
for %%? in (A) do if /I "%C%"=="%%?" goto Start-Deploy-Build
for %%? in (B) do if /I "%C%"=="%%?" goto END
:End-Choice
::END-CHOICE::
:End-Menu


::------------------------------------------------------------------------------------------------::
:: This Does the meat of the processing														      ::
::------------------------------------------------------------------------------------------------::
:Start-Deploy-Build

	For %%A IN (4.1.1.6603, 4.1.1.6659, 4.1.1.6712, 4.1.1.6751) DO CALL :Start-Deploy-Loop %%A

	:Start-Deploy-Loop
		SET TDate=%date:~10,4%-%date:~4,2%-%date:~7,2%
		SET TTime=%Time:~0,2%.%Time:~3,2%.%Time:~6,2%
		SET BTemp=%1
		SET RunTemp="%SourceDir%\Build %BTemp%\[%BTemp%]Run_Build_Scripts.bat"
		ECHO %Preamble% Deploying Build %BTemp% ON %TDate% AT %TTime% --
		ECHO %Preamble% Deploying Build %BTemp% ON %TDate% AT %TTime% --  >> %IDir%\%ILog%
		ECHO %Preamble% Running %RunTemp% --
		ECHO %Preamble% Running %RunTemp% --  >> %IDir%\%ILog%
		CALL %RunTemp%
		GOTO :EOF
	:End-Deploy-Loop


:End-Deploy-Build

:End
SET TDate=%date:~10,4%-%date:~4,2%-%date:~7,2%
SET TTime=%Time:~0,2%.%Time:~3,2%.%Time:~6,2%
ECHO %Preamble% Completed ON %TDate% AT %TTime% --
ECHO %Preamble% Completed ON %TDate% AT %TTime% --  >> %IDir%\%ILog%	

Open in new window

Ben Personick (Previously QCubed)Lead SaaS Infrastructure Engineer

Commented:
PS:  I am Using Call commands.

Why:

* CALL commands are specifically intended to be used when calling external batch files from within a batch file.

* By default they will not cause additional batch windows to open (as you are doing with the start Command).

* This will cause the main batch file to wait while the inside batch is called.  

* Output from the Batch Files is displayed in your initial command prompt.

* The Batch Files which are run will run in the context of the directory which they are sitting in instead of your main batch file's directory context (Running in the wrong directory context can cause File Not Found Errors).

* You can capture all the output of the sub batch file into a separate log file or the same log file as your main batch file is using by putting the >> redirect at the end.

* Start is really intended for running Executable files with extra parameters in a persistent DOS environment (Think Win9x).
Ben Personick (Previously QCubed)Lead SaaS Infrastructure Engineer

Commented:
Additional Items to look out for in your batch files which are being called:

If they have variables which have the Same Name (BUT ARE USED DIFFERENTLY) as the outer batch file they need to use the 'SETLOCAL" and "ENDLOCAL" command so as not to step on each other.  However, if they NEED access to the same variables, they cannot use these Key verbs as they will be unavailable.

Obviously your file not found errors are coming from the batch files which are being called.  If my script does not solve these the next step would be to examine those individual batch files for issues.

Would it be possible for you to show me the contents of the batch files?  I can probably point out the exact issue within them.  Likely there is a patch which does not have quotes; regardless I can probably tighten them up for you =)

~Q

Commented:
It is probably just a matter of spaces in filenames in the other batch files too.

Agree with comment of using CALL instead to run other batch files unless you want them to run concurrently.  if you want four in a row then do:

cd "the dir"
call yourotherbatch.cmd
cd "..\the other dir"
call yourotherbatch.cmd
cd ..

etc.

or to run at the same time lose the /B and /WAIT:

cd "first dir"
START "ver1" "ver 1.cmd"
cd "..\second dir"
START "ver2" "ver 2.cmd"

etc.

As has been said the "other" batch files can probably be optimised more too if needed, or just make sure in general that all paths and filenames have " " around them, there are some circumstances where this could break things but in the majority of cases is needed if there are any spaces in the folder or file names

Steve
Steven CarnahanAssistant Vice President\Network Manager

Commented:
Just a side note for troubleshooting:  I often REM out the @echo off at the start of a batch file and place strategic pauses throughout until I am satisfied that it is working properly. As stated, the error may not even be generated by the "main" batch file.

Using CALL is often easier than trying to run Start and is obviously less processor intensive.
Ben Personick (Previously QCubed)Lead SaaS Infrastructure Engineer
Commented:
Yeah, as I said above, I am 100% confident that the error regarding files not being found is coming from the individual batch files.

However this may be due to the context of the outer batch file contaminating them.  Please try my batch file with the "Call" methodology which may resolve the problem and the loop.

If you are still getting the errors, then, it's probably something simple like not putting quotes around your directory paths, as I said above; In which case please post the other batch files here for us, so we can take a look..

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial