Thanks for that Patrick, I will take a look at it.


"Patrick Bennett" <patrick.bennett / inin.com> wrote in message
news:3E8394E9.3000901 / inin.com...
Gavin Sinclair wrote:

On Friday, March 28, 2003, 9:55:42 AM, Nick wrote:


I am wondering if it is possible to write a Ruby script to change the
directory, inside a Command Prompt window?

What we've done at my company for some internal scripts is create a batch
file that contains Ruby code, which in turn creates a temporary batch file
which the outer batch file then executes.
ie:
Test.bat
---
@rem = '--Ruby--
@echo off
if "%TEMP%" == "" (
    echo TEMP not set
    goto exit 2>nul
)
SET ARG=%1
if "%1" == "" (
    SET ARG=nil
)
set TMP_BAT_FILE=%TEMP%\TMPBAT_%RANDOM%.bat

:exec
ruby -x -S Test.bat %TMP_BAT_FILE% %1 %2 %3
goto endofruby
@rem ';
#!ruby

# ruby code here
# write out Windows shell commands to the ARGV[0] filename
__END__
:endofruby
@echo off
if exist %TMP_BAT_FILE% call %TMP_BAT_FILE%
del %TMP_BAT_FILE% 2> nul
set TMP_BAT_FILE=