Environment Variable

Microsoft Windows xp pro w/ sp3 multilin...
November 23, 2009 at 17:16:18
Specs: Windows XP
i used the user variable(PATH) to add(;C:\Program Files\quartus\bin\cygwin\) to create a shortcut path in cmd to open the .bat file inside.

It save the time have to gone through a lot of step to open a file.

in cmd,

scenario 1:
c:Document and Settings\jason>License.txt
work(open the text file)

scenario 2
c:Document and Settings\jason>cygwin.bat
"The system cannot find the path specified"

FYI, both of the files are in the same dir.

May i know how to solve it?


See More: Environment Variable

Report •

November 23, 2009 at 21:00:36
need to list contents of "jason" (assumed batchfile?)

Report •

November 23, 2009 at 22:24:38
i don really get it. Can you explain further?


Report •

November 23, 2009 at 22:44:02
"jason" appears to direct output to files, but what is "jason" trying to do? need to know if this is a batchfile or an executable. If it's a batchfile, you need to post it's contents. if executable, you need to describe it's objective/environment and commandline setup. it seems you've given beginning and ending links in the chain, but the middle is inscrutable.my guess is that the glitch is within the "jason".

Report •

Related Solutions

November 23, 2009 at 23:41:51
Are you certain it's a .bat and not a .cmd?

This should list all of the cygwin scripts(.bat or .cmd).

dir /s /b c:\cygwin.bat c:\cygwin.cmd

Just curious, how did you add to the path variable. Are you doing it locally(non persistent) in a script or the command line, use a utility(like setx) or use the gui(win + break > advanced > environment variables)?

Also be aware that subdirectories of path directories will not be checked(i.e. \windows is normally a path dir, \windows\system32 is a separate path entry).

Batch Variable how to

Report •

November 24, 2009 at 02:49:05
To nbrane: you're thoroughly confused, but I can see how it can easily happen. Jason is the OP's username, and

C:\Documents and Settings\Jason>

is the prompt.

To Jason: are you certain the error message is saying it can't find cygwin.bat, or that it has found, and started executing, cygwin.bat but something inside cygwin.bat is generating that error message?

Report •

November 24, 2009 at 03:58:23
Klint has a very good point. The below should tell if cygwin.bat is indeed being found or not:

for %%a in (cygwin.bat) do (
    if "%%~$path:a"=="" (
        echo cygwin.bat Not found!
    ) else (
        echo cygwin.bat Found in %%~$path:a

edit: Changed script

Batch Variable how to

Report •

November 24, 2009 at 19:19:43
To Judago,

It is a bat file because the file end with .bat(MS-DOS Batch File).
I set the environment variable through use the gui, my computer>properties> advanced > environment variables.

What is the language of coding given? What software to run it?
It is the first time i use dos.

To Klint,
I just double click on the cygwin.bat file and it prompt out successfully without error.

However, i cant open in cmd(error message as mentioned before)
c:Document and Settings\jason>cygwin.bat

the content of cygwin.bat is

@echo off
set CYGWIN=nontsec nodosfilewarning
.\bin\bash --login -i

Report •

November 24, 2009 at 19:58:01
What is the language of coding given? What software to run it?
It is the first time i use dos.

It's an xp batch file. Just a simple text file with either .bat or .cmd extension. Run from command line or by executing from explorer(i.e. double click - but add a "pause" command at the end to stop the window closing).

It is a bat file because the file end with .bat(MS-DOS Batch File).

Fair enough, it was just a guess about .cmd, the reason being that .cmd is essentially equivalent to .bat on nt based system(both run by cmd.exe). The real confusion comes from "hide file extensions of known types" and .cmd having the same icon.

The script will be passed the current directory from the command line, try this

@echo off
pushd "%~dp0"
set CYGWIN=nontsec nodosfilewarning
.\bin\bash --login -i

Assuming "bin" is in the same directory as the batch.

"%~dp0" is just a modifer to argument %0(the script that it running) that expands to it's path and drive. Pushd changes and stores the current directory, popd restores the directory from before calling pushd.

One thing I forgot to mention, you don't need the .\ to run a "non-path" executable on the windows command line, the relative path "bin\bash" is sufficient. The .\ (current directory) won't do any harm though....

You could also avoid "pushd" and "popd" by using:

"%~dp0\bin\bash" --login -i

Batch Variable how to

Report •

November 25, 2009 at 03:05:40
Judago has found the cause of the problem. I would recommend his second solution, to modify the bash line to use

"%~dp0\bin\bash" --login -i

This is preferable to using pushd and popd as the latter would keep the batch file in context (and using up resources) while you are using Cygwin at the bash command line prompt.

Just to clarify, the reason you were getting the error is that, although you had the Cygwin directory in your PATH, and could access the Cygwin.bat file, the line ".\bin\bash" does not look at the PATH, and instead explicitly looks in your current directory. The problem is that Cygwin.bat was designed to work only from its own directory. This is unnecessarily restrictive, and easily fixed.

By the way, you are not using DOS, you are using the Win32 Command Processor. Windows XP does not have DOS.

Report •

Ask Question