This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: find the path for cygwin root from windows script


Luc Hermitte a écrit:

Hello,

* On Thu, Jun 17, 2004 at 11:12:00AM +0200, bertrand marquis <bertrand_marquis@yahoo.fr> wrote:


i need to be able to find where cygwin is install from a .bat script under windows to run cygwin programs.
Does anyone has a solution to do that automaticaly ?



cygpath -m /


I agree that is working but only if your path is set correctly and to do that you need to know where cygwin has been installed


However, this solution requires that cygwin directories are visible from your $PATH. In other words, you won't really need to know where they are installed.



Anyway i found a solution looking into the windows registry where this is writting when cygwin is installed.
Here is an example which start an xterm.


::start of file xterm.bat
@echo off
SET DISPLAY=127.0.0.1:0.0

REM Look for cygwin entry in windows registry
REGEDIT /E %Temp%.\tmp-cygwin.reg "HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2\/"> nul


REM Check if something has been found
if not exist %Temp%.\tmp-cygwin.reg goto EXITNOCYGWIN

REM Get the native key from windows registry result
FOR /F "tokens=1* delims==" %%A IN ('TYPE %Temp%.\tmp-cygwin.reg ^| FIND "native"') DO SET CYGWIN_ROOT=%%B> nul


REM Remove quotes
SET CYGWIN_ROOT=%CYGWIN_ROOT:"=%> nul

REM Remove temporary file
if exist %Temp%.\tmp-cygwin.reg del %Temp%.\tmp-cygwin.reg

REM Check if we have found something
if "%CYGWIN_ROOT%" == "" goto EXITNOCYGWIN

REM Export Cygwin path
SET PATH=.;%CYGWIN_ROOT%\bin;%CYGWIN_ROOT%\usr\X11R6\bin;%CYGWIN_ROOT%\opt\elinos\bin;%PATH%


run xterm

exit

:EXITNOCYGWIN
echo no cygwin entry has been found in registry
pause

::end of file

I only have two questions left:
- is HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2 always the place where i can find the mounts in the registry


- is there a way to check that there is actually a X server running on 127.0.0.1 from a windows script. As this if there isn't i could start one.



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]