0

I really need help getting a .bat file to run from the Task Scheduler.

  • It runs when ran from location manually or when Run is clicked from Task Scheduler.
  • It doesn't 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
  • The .bat file is stored in C:\Users\user1\eclipse-workspace\abc\, and this is what I have filled in for the Program/Script under Settings in Actions tab.
  • I have unchecked all options under the Conditions tab, (tried checking the power options, still didn't work).

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

Question: Is there something I'm missing or that I have setup or configured wrong that is causing this script to not run on the scheduled task?


The .bat file code

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
Vomit IT - Chunky Mess Style
  • 40,038
  • 27
  • 84
  • 117
Gina Gina
  • 101
  • 1
  • 3
  • Does the batch file perform any network specific tasks to mapped network shares? If so, remember to add the mappings in your script, because when you run whether the user is logged in or not, it will not run as your user but as SYSTEM user, and that means the login script is not run, so no network shares were made. – LPChip May 25 '18 at 21:14
  • When you set the task to run when the user is not logged in, the operating system sets the working directory to system32 when task scheduler launches the script. – Squashman May 25 '18 at 21:22
  • @Squashman, so whats your resolution on this? – Gina Gina May 25 '18 at 21:35
  • @LPChip can you please tell me how can i add the mappings? This is my code : – Gina Gina May 25 '18 at 21:36
  • @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:36
  • 1
    Don't post your code in comments. Edit your question. Your code does not look line a Windows batch-file so I am not sure why you are using that tag. – Squashman May 25 '18 at 21:41
  • question edited – Gina Gina May 25 '18 at 21:56
  • Gina - Read over my post here: https://superuser.com/questions/1214736/windows-10-scheduled-tasks-with-workstation-lock-unlock-not-being-triggered/1217125#1217125 for some helpful tips that may assist you in resolving this as well or at a minimum otherwise give you some additional things to try and/or eliminate if you've not already. – Vomit IT - Chunky Mess Style May 26 '18 at 03:55
  • unfortunately @PimpJuiceIT that didnt work. – Gina Gina May 27 '18 at 13:19
  • Hi Gina - My next suggestion would be for you to right click on the scheduled task and select the "export" option and then save that to an XML file. Then open that XML file where you saved it to with a text editor such as notepad and then copy the contents of it, and then [edit] your post and add this detail to your post. Feel free to mask out any sensitive information you feel should not be disclosed if you want and use `*****` or some dummy value in its place if you want and feel it's sensitive. This may help us see something being overlooked potentially and is very easy and simple. – Vomit IT - Chunky Mess Style May 27 '18 at 16:35

0 Answers0