1

I really need help on running a .bat file from the Task Scheduler.

It runs when ran from location or when Run is clicked from Task Scheduler.

It doesnt run on a schedule when Run only when user is logged on / Run when user is logged on or not

The user is my local account is also the admin

.bat file is stored in C:\Users\user1\eclipse-workspace\abc\, and this is what iI have filled in for the Program/Script under Settings in Actions tab.

I have unchecked all options under Conditions tab, (tried checking the power options, still didnt work).

I would prefer to have this option set :: Run when user is logged on or not.

I would like to know what I'm missing or where I'm going wrong with this.

.bat file code is :

cd C:\Users\user1\eclipse-workspace\abc
set ProjectPath=C:\Users\user1\eclipse-workspace\abc
echo %ProjectPath%
set classpath=%ProjectPath%\bin;%ProjectPath%\Lib\*
echo %classpath%
java org.testng.TestNG %ProjectPath%\testng.xml
pause
AlexP
  • 4,370
  • 15
  • 15
Gina Gina
  • 2,915
  • 2
  • 10
  • 16
  • In the 'Start In' field put the filepath C:\Users\user1\eclipse-workspace\abc\ Then in the Program/Script put just the name of the bat file without the path. Let me know if that works for you. – DrHouseofSQL May 25 '18 at 19:55
  • already tried that, but it didnt work – Gina Gina May 25 '18 at 19:56
  • Under security options have you tried enabling the 'Run with highest privileges' option? – DrHouseofSQL May 25 '18 at 19:59
  • The only other thing to try (odd as it may seem) is to toggle the 'Configure for' dropdown setting on the General tab. Try all the selections and see if one works. – DrHouseofSQL May 25 '18 at 20:02
  • yes its enabled with Run with highest privilges. Also it asks me for password. – Gina Gina May 25 '18 at 20:04
  • Tried checking with all dropdown options under Configure - still no luck, – Gina Gina May 25 '18 at 20:07
  • 2
    This site is for help with your code issues, if you're not providing code, your question is off topic, _and would have been better on [Super User](https://superuser.com/questions/ask), where general questions regarding the use of the OS software belong. – Compo May 25 '18 at 20:20
  • Need to see the script. – Squashman May 25 '18 at 20:50
  • Actually the script runs when " Run when user is logged in" and when Run is manually clicked from task scheduler, but ti doesnt run ona schedule – Gina Gina May 25 '18 at 20:52
  • @GinaGina if you are not going to show us your code the users with enough reputation will vote to close your question. – Squashman May 25 '18 at 21:19
  • @Test public static void currFetch() throws InterruptedException, FileNotFoundException { System.setProperty("webdriver.chrome.driver", Constants.driverPath+"chromedriver.exe"); WebDriver driver= new ChromeDriver(); driver.navigate().to("https://www.google.com"); }} – Gina Gina May 25 '18 at 21:34

1 Answers1

0

This one saved me:

  • Make sure "Run with highest privileges" is turned off in your task scheduler settings
  • In your bat file, use pushd \\network_drive_name as the first line of code
  • At the end of your bat file, use popd \\network_drive_name
Stephan
  • 53,940
  • 10
  • 58
  • 91
anish
  • 88
  • 6