#Create the function (Windows environment)
run_knime_workflow <- function(knime_home, workflow_directory, reset, nosplash, consoleLog, nosave, additional_options) {


if(missing(reset)) {reset_string <- "-reset"} else {if(reset == TRUE) {reset_string <- "-reset"} else {reset_string <- ""}}


if(missing(nosplash)) {nosplash_string <- "-nosplash "} else {if(nosplash == TRUE) {nosplash_string <- "-nosplash"} else {nosplash_string <- ""}}


if(missing(consoleLog)) {consoleLog_string <- ""} else {if(consoleLog == TRUE) {consoleLog_string <- "-consoleLog"} else {consoleLog_string <- ""}}


if(missing(nosave)) {nosave_string <- ""} else {if(nosave == TRUE) {nosave_string <- "-nosave"} else {nosave_string <- ""}}


if(missing(additional_options)) {additional_options_string <- ""} else {additional_options_string <- additional_options}



shell(paste0("cd ", knime_home, " & knime.exe ", reset_string, " ", nosplash_string," ", consoleLog_string, " ", nosave_string," ",additional_options_string, " ", " -application org.knime.product.KNIME_BATCH_APPLICATION ", "-workflowDir=\"", workflow_directory,"\""), wait=TRUE)


}

#Run an example
run_knime_workflow(knime_home="C:/Program Files/KNIME", workflow_directory="C:/knime workspace/my_workflow", nosplash=TRUE, reset=TRUE, consoleLog=FALSE, nosave=FALSE, additional_options="--launcher.suppressErrors")