Can someone suggest why this script is failing?
Posted: 23 Sep 2011 08:10
Thanks in advance.
@Echo Off
SetLocal EnableDelayedExpansion
::Script to input text from a text file, and check each line to see if it starts "curPath: "
::Once the "curPath: " line has been identified, save it to a variable
Set _InputFile=F:\Locations.txt
for /f "tokens=* delims= " %%a in (%_InputFile%) do (
set /a N+=1
set v!N!=%%a
set vPath=!v!N!
::Remove the first 9 characters of the text line and check if it starts "curPath: "
if %vPath:~9% == "curPath: "
varPath == vPath
)
::Trim the path
set varPath=%varPath:curPath: =%
::echo %varPath%
IF "%varPath"=="Path1" set appPath="C:\Path1.py"
IF "%varPath"=="Path2" set appPath="C:\Path1.py"
IF "%varPath"=="Path3" set appPath="C:\Path1.py"
IF "%varPath"=="Path4" set appPath="C:\Path1.py"
start "" "%appPath%"
@Echo Off
SetLocal EnableDelayedExpansion
::Script to input text from a text file, and check each line to see if it starts "curPath: "
::Once the "curPath: " line has been identified, save it to a variable
Set _InputFile=F:\Locations.txt
for /f "tokens=* delims= " %%a in (%_InputFile%) do (
set /a N+=1
set v!N!=%%a
set vPath=!v!N!
::Remove the first 9 characters of the text line and check if it starts "curPath: "
if %vPath:~9% == "curPath: "
varPath == vPath
)
::Trim the path
set varPath=%varPath:curPath: =%
::echo %varPath%
IF "%varPath"=="Path1" set appPath="C:\Path1.py"
IF "%varPath"=="Path2" set appPath="C:\Path1.py"
IF "%varPath"=="Path3" set appPath="C:\Path1.py"
IF "%varPath"=="Path4" set appPath="C:\Path1.py"
start "" "%appPath%"