Search code examples
rubycommand-linewindows-consolebackticks

How to execute Windows CLI commands in Ruby?


I have a file located in the directory "C:\Documents and Settings\test.exe" but when I write the command `C:\Documents and Settings\test.exe in single qoutes(which I am not able to display in this box), used for executing the commands in Ruby, I am not able to do so and the error that I recieve is No file or Directory found. I have tried replacing "\" with "//" and "\" but nothing seems to work. I have also used system, IO.popen and exec commands but all efforts are in vain. Also exec commands makes the program to make an exit which I don't want to happen.

Thanks in advance.


Solution

  • `"C:\Documents and Settings\test.exe"`
    

    or

    `exec "C:\Documents and Settings\test.exe"`
    

    or whatever in qoutes