Running script from bat file - saveWidget function requires pandoc Error

Hey, I have a similar problem as here:
saveWidget function in an old script - R Markdown - Posit Community (

The difference is, that I have pandoc installed and when I am running my shiny app via RStudio, there is no issue, everything works as intended.

But when I am running the script through a bat file shortcut, I get the error from the browser: "Couldn't download, something went wrong..."
And in the logs its stating: "Warning: Error in pandoc_self_contained_html: Saving a widget with selfcontained = TRUE requires pandoc. See here to learn more 1.1 Use a Pandoc version not bundled with the RStudio IDE | R Markdown Cookbook
1: shiny::runApp"

The application:

  ui <- fluidPage(
    downloadButton("downloadData", "Download")
  server <- function(input, output) {
    data <- mtcars
    plot1 <- ggplot2::ggplot(mtcars, aes(x = cyl, y = hp))+
    plot <- ggplotly(plot1)
    output$downloadData <- downloadHandler(
      filename = function() {
        paste("data-", Sys.Date(), ".html", sep="")
      content = function(file) {
        htmlwidgets::saveWidget(plot, file, selfcontained = T)
  shinyApp(ui, server)

And my bat file:

"C:/Program Files/R/R-4.2.0/bin/R.exe" -e "shiny::runApp('C:/Users/user/Desktop/Download.R', launch.browser = TRUE)"

Many thanks

Found the answer only a few minutes after I posted this...

r - How to address the pandoc issue - Stack Overflow

So I just used


And then added/copy pasted the path to paths, using this tutorial:
What is Windows PATH and How Do You Add to and Edit it? - Make Tech Easier

Now everything works as intended.