trouble with setlocal

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
regaw_leinad
Posts: 4
Joined: 26 Mar 2010 14:25

trouble with setlocal

#1 Post by regaw_leinad » 26 Mar 2010 14:40

Code: Select all

setlocal enabledelayedexpansion
FOR /F "usebackq delims=" %%G IN ("p1ds1.txt") DO (
Set "line=%%G" & echo !line:A          =!
)>>"p1ds2.txt"

FOR /F "usebackq delims=" %%G IN ("p1ds2.txt") DO (
Set "line=%%G" & echo !line:%zip%.zip=!
)>>"p1ds3.txt"
endlocal


this is what I have for a search function to grab the path of the file I input. This is just a small part of my whole script.
My question is that after this (even with endlocal) none of my regular commands work, ie xcopy, java (yes i have java set up on my comp)
they just come up with '(command here)' is not recognized as an internal or external command, program or batch script...
They all work fine in a regular cmd window, but not in my bat after the setlocal/endlocal part.

any reasons why? thanks for your help :)

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: trouble with setlocal

#2 Post by aGerman » 26 Mar 2010 15:11

Imho the endlocal command should not be the problem.

Because of this statement:
regaw_leinad wrote:this is what I have for a search function to grab the path of the file I input.

I speculate that you change the "path" environment variable somewhere and thats why the the commands can't be found.
Have a look to your code and serch for something like
set path=...
and change it to say
set Xpath=...

Regards
aGerman

regaw_leinad
Posts: 4
Joined: 26 Mar 2010 14:25

Re: trouble with setlocal

#3 Post by regaw_leinad » 26 Mar 2010 15:19

wow, I can't believe I missed that. Thank you so much for helping me :)

Post Reply