views:

334

answers:

4

hi there*.sh im not really feeling home in the windows world but at the moment i have to use a laptop with windows xp installed on it... the point is, that i do not have administrator privileges. Im currently working on a grails application and therefore I have to set the JAVA_HOME and GRAILS_HOME eacht time, I start the machine... Could anyone be so kind and give me a hint how to write such a script. Obvioulsy the script wont do much just set the respective Home directories for Java and Grails... All I know that the file should probably have a sh-extension... Thanks in advance....

A: 

You would want a file with .bat extension for Windows.

SET JAVA_HOME=path
SET GRAILS_HOME=path
Android
A: 

On Windows, you could write a .BAT file (BATch), and then simply double-click it each time you log in. a .BAT file is simply a plain text file filled with any commands you would normally issue at the command prompt, e.g.:

cd c:\Temp c: set PATH=%PATH%;c:\Program Files\Some Directory\Some Subdirectory

You can optionally precede each line with the @ symbol to stop it being echoed to the command window when it executes.

JTeagle
A: 

Try calling the following :

SETX JAVA_HOME path
SETX GRAILS_HOME path

If you're allowed they will be set in your profile and you won't need to run them again hopefully. Other wise you'll need to follow @Android's answer

Preet Sangha
`setx` doesn't exist on vanilla Windows XP, unfortunately.
Joey
whoops sorry keep forgetting that
Preet Sangha
+2  A: 

You surely can set the environment variables with a batch file each time you need them, but bear in mind that this will only work for the current process (i. e. the cmd instance you're invoking the batch from) and processes spawned from there. I think you'd rather want persistent environment variables.

Now, in the UNIX world you'd just put them into your shell startup script. In Windows ... not exactly that way.

  1. Right click on "My Computer", select "Properties".
  2. There, go to the "Advanced" tab
  3. Click the button labeled "Environment variables"
  4. You can set JAVA_HOME and GRAILS_HOME under "User variables" there.

You would only need administrator access for changing the system environment variables.

Joey
Thanks - that worked like a charm...
Gnark