# Running a script in InstantRails

**URL:** <https://www.ruby-forum.com/t/running-a-script-in-instantrails/136729>\
**Category:** Rails\
**Created:** [May 5, 2008, 10:22pm UTC](https://www.ruby-forum.com/t/running-a-script-in-instantrails/136729 "2008-05-05T22:22:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sithadmin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/858c86/32.png) [@sithadmin](https://www.ruby-forum.com/u/sithadmin)\
**Post date:** [May 5, 2008, 10:22pm UTC](https://www.ruby-forum.com/t/running-a-script-in-instantrails/136729/1 "2008-05-05T22:22:23Z")

</div>

Hello,  
I have a program built in InstantRails 1.6 on Windows Server 2003. I  
have a script, located in the script folder. I also have a windows  
version of Cron, which points to that script. However, it doesn’t seem  
to execute properly. If I call it from a controller in my app, it works  
fine using `script/myscript.rb` however, when I simply double-click it  
in windows explorer, a command window pops up briefly (less than a  
second) and closes, not executing anything. How am I to run my script  
from anywhere, not just rails?

Any and all help is appreciated!

Thanks,

- Jeff M.

---

<div class="post-metadata">

**Author:** ![sithadmin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/858c86/32.png) [@sithadmin](https://www.ruby-forum.com/u/sithadmin)\
**Post date:** [May 5, 2008, 10:48pm UTC](https://www.ruby-forum.com/t/running-a-script-in-instantrails/136729/2 "2008-05-05T22:48:03Z")

</div>

FYI, on a test script I created (which just creates a txt file and puts  
in some lines) I noticed that it will work if I don’t load up the  
environment. However, when I put

require File.expand\_path(File.dirname( **FILE** ) +  
“/…/config/environment”)

at the top, it exits the program as soon as it starts… I need to use  
this so I can access my models from that script, so I am not quite sure  
how to go about this…

Any advice?

Thanks,

- Jeff M.

---

<div class="post-metadata">

**Author:** ![sithadmin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/858c86/32.png) [@sithadmin](https://www.ruby-forum.com/u/sithadmin)\
**Post date:** [May 5, 2008, 11:54pm UTC](https://www.ruby-forum.com/t/running-a-script-in-instantrails/136729/3 "2008-05-05T23:54:35Z")

</div>

A coworker of mine helped me figure out that I am having this problem  
because Ruby is not installed on the system, as it is only available via  
Ruby on Rails (InstantRails 1.6). Is there a way I can “expand” this so  
that I can use it outside of Rails?

Thanks,

- Jeff
