2

I am a newbie in writing batch files and need help.

I want to do the following tasks using a single batch file.

1) Start cmd 2) Change directory to C:\Program Files\Microsoft\MRO\R-3.3.0\bin 3) Run a R script there

I know I can achieve this if I write the command as follows :

    cmd.exe /K "cd C:\Program Files\Microsoft\MRO\R-3.3.0\bin && Rscript BlowerHealthIntegration.R 0.753975708353173 0.16874738612188295 0.028476842398414307 -0.014617814348478057 0.6436494038934525 0.17659988446055574 0.007223245126697915 -0.014617814348478057"

But the main problem is I have to write everything in a single line.

How can I split them into separate lines ?

Say I want to write something like this

    cmd.exe
    C:\Program Files\Microsoft\MRO\R-3.3.0\bin
    Rscript BlowerHealthIntegration.R 0.753975708353173 0.16874738612188295 0.028476842398414307 -0.014617814348478057 0.6436494038934525 0.17659988446055574 0.007223245126697915 -0.014617814348478057

This is like entering each command after pressing enter. How can I achieve this in Windows 7 x64 bit.

1
  • 2
    Note that a Batch.bat file is executed by the cmd.exe processor automatically. In other words, you usually don't need to invoke cmd.exe in a Batch file (unless you are using some advanced method); just put the desired commands in the .bat file, one per line... Commented Aug 21, 2016 at 14:16

1 Answer 1

1

Give a try for this code and tell me the results :

@echo off
CD /D "%ProgramFiles%\Microsoft\MRO\R-3.3.0\bin\"
Rscript "BlowerHealthIntegration.R 0.753975708353173 0.16874738612188295 0.028476842398414307 -0.014617814348478057 0.6436494038934525 0.17659988446055574 0.007223245126697915 -0.014617814348478057"
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for your answer. The first problem is that it instantly turns off. So I added timeout 25 at end to make the output visible a bit longer. But another error states that "No such file or directory" . But the file is there.
Please remove or comment out the @echo off line. Then, copy and paste the output when running the script at the cmd shell prompt. Post it in the question, not in a comment like this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.