Thanks to Aubin, when I use the absolute path for /tr argument in schtasks.ext, everything works. And
It's because the current directory isn't set by task scheduler when it's set by explorer.exe when you double click the batch file .
Pergunta
I am right now using windows 7 machine. And I was trying to start the selenium test by task scheduler. I used a bat file to include all the command I need to compile and run the selenium test. And for the selenium test, I use java. So what's in the script would be like
cd C:\Users\test\Documents\SevOneNMS\qa\automation
C:\"Program Files"\Java\jdk1.7.0\bin\javac -d C:\Users\test\Documents\tmp -classpath .;../../../jars/junit-4.11.jar;../../../jars/jsch-0.1.49.jar;../../../jars/commons-net-3.1.jar;../../../jars/selenium-server-standalone-2.31.0.jar;tmp;../../../config tests/alerts/AlertActions.java
cd C:\Users\test\Documents\tmp
java -classpath .;../jars/junit-4.11.jar;../jars/jsch-0.1.49.jar;../jars/commons-net-3.1.jar;../jars/selenium-server-standalone-2.31.0.jar org.junit.runner.JUnitCore tests.alerts.AlertActions
when I run this bat file directly under windows 7, it works perfectly fine. But when start it by task scheduler, the command line widows only pop up for half second and disappeared, there is no error message and test was not executed at all. Below is the command line for task scheduler(Testing.bat is the bat file I'm talking about). And I don't why it's not working. Please help.
schtasks /create /tr Testing.bat /tn selenium /sc ONCE /st 05:55 /f
schtasks /run /tn selenium
schtasks /delete /tn selenium /f
Solução
Thanks to Aubin, when I use the absolute path for /tr argument in schtasks.ext, everything works. And
It's because the current directory isn't set by task scheduler when it's set by explorer.exe when you double click the batch file .