Page 1 of 1

Echoing code to a certain point in a batch file

Posted: 19 Oct 2011 00:23
by Rileyh
I am hoping that someone could tell me how to do the following.
I would like to make a batch file where someone has to set up an "account". But then once they have made their "account", the batch file places

Code: Select all

chdir /D (whatever the directory they have made their account in)

into the very start of the batch file's code so that it can go straight to the "login" part instead of following the "setup" path.

Any help would be appreciated,
Rileyh

Re: Echoing code to a certain point in a batch file

Posted: 28 Oct 2011 10:36
by aGerman
What is this good for? Just pass the new path as parameter and find it as %1.

bat1.bat

Code: Select all

@echo off
echo this is bat1
call "bat2.bat" "C:\Windows"
echo this is bat1 again
pause


bat2.bat

Code: Select all

@echo off
echo this is bat2
echo current directory is "%cd%"
if exist "%~1" cd /d "%~1"
echo new directory is "%cd%"
:: your stuff here

Regards
aGerman