0

I want to execute a jar file in Windows Task Scheduler and I exactly followed all the instructions here : https://stackoverflow.com/a/26932169/5118389

Start program : "C:\Program Files (x86)\Java\jre6\bin\java.exe" (tried also with javaw.exe) Arguments

-jar "D:\fold\tool.jar" -simul > "D:\fold\report\last_scan.txt"
Start in D:\fold

When i execute manually this command in commandline, everything is working fine and my output file is generated! But with Windows Task Scheduler when I click on run, nothing happens and no output file is generated!

Could you help me?

Community
  • 1
  • 1
Learthgz
  • 133
  • 12

1 Answers1

-1

Hope this could help:

    <?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
  <RegistrationInfo>
    <Date>2015-12-14T11:26:48.2627112</Date>
    <Author>DOMAIN\MyUsername</Author>
  </RegistrationInfo>
  <Triggers />
  <Principals>
    <Principal id="Author">
      <UserId>DOMAIN\MyUsername</UserId>
      <LogonType>Password</LogonType>
      <RunLevel>HighestAvailable</RunLevel>
    </Principal>
  </Principals>
  <Settings>
    <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
    <DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>
    <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
    <AllowHardTerminate>true</AllowHardTerminate>
    <StartWhenAvailable>false</StartWhenAvailable>
    <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
    <IdleSettings>
      <StopOnIdleEnd>true</StopOnIdleEnd>
      <RestartOnIdle>false</RestartOnIdle>
    </IdleSettings>
    <AllowStartOnDemand>true</AllowStartOnDemand>
    <Enabled>true</Enabled>
    <Hidden>false</Hidden>
    <RunOnlyIfIdle>false</RunOnlyIfIdle>
    <WakeToRun>false</WakeToRun>
    <ExecutionTimeLimit>P3D</ExecutionTimeLimit>
    <Priority>7</Priority>
  </Settings>
  <Actions Context="Author">
    <Exec>
      <Command>"C:\Program Files\Java\jdk1.7.0_67\bin\java.exe"</Command>
      <Arguments>-jar "MyPathToJar"</Arguments>
      <WorkingDirectory>MyPath</WorkingDirectory>
    </Exec>
  </Actions>
</Task>

Apparently it's not clear what you've done but in the above template provided try changing <Author>, <UserId>, <Command>, <Arguments>, <WorkingDirectory> with your own properties and then import the entire xml on the scheduler.

Remember to set the execution with the highest privileges.

It's worth to give it a try.

Andrea Grimandi
  • 631
  • 2
  • 8
  • 32