Sample run.bat file
echo "Test"
echo %1
echo %2
set /p DUMMY=Hit ENTER to continue...
So this bat file will print the first two arguments that are given to them. The arguments may or may not contain spaces. For that I have escaped them with Double quotes.
run.bat -test "arg2 d"
It worked perfectly fine,when called via command line.
I wanted to schedule that bat via Task Scheduler. But the task scheduler opens a cmd window and closes immediately.
Not Working
Working
Note the quote in arguments. That is causing the issue. So how can I escape the argument with spaces.
Also if the Program/Script file location is entered without quotes then the arguments is working. but for that the script has to be in a folder without spaces.
Error in Action
So how to create a task with space in file path and arguments with spaces as well.
Its happening only in Windows 10. It's working fine in windows 7 btw.
I had a similar issue. I was running a scheduled task on Server 2012 R2. I had to change the dropdown of the task to Windows 2012 rather than 2008 and it seemed to work. Maybe Win10 needs 2012 selected in the task as well.