relative path problem

O

Osiris

I have this .BAT file:
===========================
if "%1" == "sfx" (
cd xampp
)
if exist php\php.exe GOTO Normal
if not exist php\php.exe GOTO Abort

:Abort
echo Sorry ... cannot find php cli!
echo Must abort these process!
pause
GOTO END

:Normal
set PHP_BIN=php\php.exe
set CONFIG_PHP=install\install.php
%PHP_BIN% -n -d output_buffering=0 %CONFIG_PHP%
GOTO END

:END
pause
===================================
the BAT file is in C:\Program Files\xampp
the php.exe file is in C:\Program Files\xampp\php
When I click on the BAT file, the system cannot find the php.exe
program. but it is surely there.
I get the two echo's after :Abort.

What can be the cause of it ?
On another WinXPSP2 machine all is OK.
 
O

Osiris

new info:
when I add
DIR
at the beginning of the BAT script, I always get to see the DIR of C:\
even when the script is in D:\bla\blo\ble and I click it there.

So suddenly, BAT scripts execute "in" the C: root...
that is weird, considering the script IS in C:\program file\xampp.
 
A

Ayush

Replid to [Osiris]s message :
-----------------------------------------------------------
new info:
when I add
DIR
at the beginning of the BAT script, I always get to see the DIR of C:\
even when the script is in D:\bla\blo\ble and I click it there.

So suddenly, BAT scripts execute "in" the C: root...
that is weird, considering the script IS in C:\program file\xampp.

Try this :
===========================
if "%1" == "sfx" (
cd /d "C:\Program Files\xampp"
)
cd
if exist "php\php.exe" GOTO Normal
if not "exist php\php.exe" GOTO Abort
echo Sorry ... cannot find php cli!
echo Must abort these process!
pause
GOTO END
set PHP_BIN=php\php.exe
set CONFIG_PHP=install\install.php
%PHP_BIN% -n -d output_buffering=0 %CONFIG_PHP%
GOTO END
pause
===================================

After the first if (), there is cd. It will tell you where you are so that you
can verify that you are in C:\Program files\Xampp
 
O

Osiris

Replid to [Osiris]s message :
-----------------------------------------------------------
new info:
when I add
DIR
at the beginning of the BAT script, I always get to see the DIR of C:\
even when the script is in D:\bla\blo\ble and I click it there.

So suddenly, BAT scripts execute "in" the C: root...
that is weird, considering the script IS in C:\program file\xampp.

Try this :
===========================
if "%1" == "sfx" (
cd /d "C:\Program Files\xampp"
)
cd
if exist "php\php.exe" GOTO Normal
if not "exist php\php.exe" GOTO Abort
echo Sorry ... cannot find php cli!
echo Must abort these process!
pause
GOTO END
set PHP_BIN=php\php.exe
set CONFIG_PHP=install\install.php
%PHP_BIN% -n -d output_buffering=0 %CONFIG_PHP%
GOTO END
pause
===================================

After the first if (), there is cd. It will tell you where you are so that you
can verify that you are in C:\Program files\Xampp

Yeah, a cd in the BAT script works ok, but that is not the issue.
Why does the BAT file not execute with a default folder of where the
BAT file itself is in ?
It always did....
It does on my other computer....
the sfx stuff is not relevant, because there is no commandline option,
when I click the BAT script in WinXP.
 
A

Ayush

Yeah, giving parameter changes the location. I read this somewhere and tested
this. On my computer, it changes to C:\windows\Fonts. I dont know why.

--
Ayush [ Be ''?'' Happy ]
-------------
Search - www.Google.com | Wikipedia - http://en.wikipedia.org
Snip your long urls - http://snipurl.com/
-------------


Replid to [Osiris]s message :
-----------------------------------------------------------
Replid to [Osiris]s message :
-----------------------------------------------------------
new info:
when I add
DIR
at the beginning of the BAT script, I always get to see the DIR of
C:\ even when the script is in D:\bla\blo\ble and I click it there.

So suddenly, BAT scripts execute "in" the C: root...
that is weird, considering the script IS in C:\program file\xampp.

Try this :
===========================
if "%1" == "sfx" (
cd /d "C:\Program Files\xampp"
)
cd
if exist "php\php.exe" GOTO Normal
if not "exist php\php.exe" GOTO Abort
echo Sorry ... cannot find php cli!
echo Must abort these process!
pause
GOTO END
set PHP_BIN=php\php.exe
set CONFIG_PHP=install\install.php
%PHP_BIN% -n -d output_buffering=0 %CONFIG_PHP%
GOTO END
pause
===================================

After the first if (), there is cd. It will tell you where you are
so that you can verify that you are in C:\Program files\Xampp

Yeah, a cd in the BAT script works ok, but that is not the issue.
Why does the BAT file not execute with a default folder of where the
BAT file itself is in ?
It always did....
It does on my other computer....
the sfx stuff is not relevant, because there is no commandline option,
when I click the BAT script in WinXP.
 
O

Osiris

I think I found the cause:
there is a registry key AUTORUN that does it:

[HKEY_CURRENT_USER\Software\Microsoft\Command Processor]
"CompletionChar"=dword:00000009
"DefaultColor"=dword:00000000
"EnableExtensions"=dword:00000001
"Autorun"="CD /D C:\\"

I got rid of it and now things seem to be normal.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top