set file="C:\\r_work\\exec\\output.txt" echo; >>C:\r_work\exec\script.R echo; >>C:\r_work\exec\script.R echo fileConn=file(%file%)>>C:\r_work\exec\script.R echo writeLines(getwd(), fileConn)>>C:\r_work\exec\script.R echo close (fileConn)>>C:\r_work\exec\script.R C:\"Program Files"\R\R-2.13.0\bin\i386\R.exe CMD BATCH script.R