madhu
madhu

Reputation: 13

How to open a command prompt window in ruby script and have an interactive session

I have a requirement where i need to open command prompt and run a bat file, this bat file will ask for the user to enter a choice 2 to 3 times, how to automate this in ruby in windows.

Am able to open command prompt using

system("start cmd.exe")

After this I need to change directory and then i need to run the file present in c://temp//dat.bat, through ruby script.

Please let me know how to automate all these operations.

Upvotes: 1

Views: 4738

Answers (1)

marc
marc

Reputation: 6223

cmd_line = "cmd.exe /c \"cd #{directory}&&#{bat_file}\""
system(cmd_line) # if you're not interested in the output

Should do it.

Upvotes: 1

Related Questions