The problem: When I double click the .bat file it executes as expected. When I schedule it in Windows Task Scheduler it executes except the line that has cscript.
Content of .bat file:
@echo off
cls
cscript CSV_To_Excel.vbs c:\tableaudata\test.csv c:\tableaudata\test.xlsx
echo.file converted >>log.txt
What is throwing me off is the fact that log.txt gets created indicating that the .bat file is being executed. But .xlsx is not created. However, on manually double clicking .bat both log.txt and test.xlsx is created.
What could be the problem?
To help debug the situation, add the following to the end of your cscript command line:
Then, check to see if the c:\MyCScriptOutput.txt file has any error message(s) in it. If it does, please add this information (both the command line and the output) to your question.
I'm speculating, but the problem might be that cscript is trying and failing to run interactively, so you could try replacing "cscript" in your command line with "cscript //Nologo //B", to see if that fixes it.
Resolved!! In the windows task scheduler I had to click "change user or group" button and add "Administrators" group.
The main problem is you don't specify full path to your CSV_To_Excel.vbs Scheduler execute script from c:\windows\system32 (where schtasks.exe located) So, your batch call to cscript should be