Running a .bat file in Scheduled Task - scheduled-tasks

I am using a Windows Server 2008 machine where I need to run a batch file as a Scheduled Task. The scheduled batch file is not running, but when I click the batch file manually its running with no problem.
The Content of the batch file is as follows:
cd E:\SOAPUI\soapui-2.0.2\bin
e:
testrunner.bat -sDev_Test -a -j -f "D:\DocRepos\LensWebSvc\SOAPUI-Reports(Lens)"
"D:\DocRepos\LensWebSvc\SOAPUI\LensWebServiceTest(Lens)-soapui-project.xml"
Can anyone help me to run the batch file in scheduled task?

It could be a few things. Make sure you've set the task to start in the same path that the batch file is located. Also, make sure the account running the task has permission to run the task and access the location of the batch file.

Related

Jenkins windows slave batch job says success but job did not run

Trying to set up a jenkins v2.46.3 slave on windows 2016 server to run a batch file.
It looks like it is working but the batch file does not actually run. The script does not generate the expected log file and nothing shows up in task manager on the slave
The console output of the job looks like this:
Started by user xxx
Building remotely on xxx-Windows (windows) in workspace c:\Jenkins\workspace\xxx
[xxx] $ cmd /c call C:\Windows\TEMP\hudson4948156451026881586.bat
c:\Jenkins\workspace\xxx>C:\QA\xxx\Perl\Tests\runxxxTests.bat
c:\Jenkins\workspace\xxx>cd C:\QA\xxx\Perl\Tests
C:\QA\xxx\Perl\Tests>runxxxTests.pl -f test_suite_test.list
Finished: SUCCESS
If I run the batch file manually it works as expected.
There do not seem to be any errors. How can I troubleshoot this further ?
The fix to this was changing the log on rights of the Jenkins and Jenkins Agent services on the windows slave from LocalSystem to a privileged account.

Script not running via Task Scheduler

I have to deploy some Perl automation scripts on a server. But to schedule them I am using Windows Task Scheduler. I have a .bat file in which I have written the command
perl scriptname.pl
Provided the .bat file and script are in same directory which is in D: drive. But the task scheduler always triggers and then gives error that previous instance is already running.
I don't want to override the instance but I cannot see any instance running. Also the script is a selenium script and I am not seeing any browser window which I generally see when the task is triggered by the Scheduler.
The script is working fine on excuting the .bat file directly.

Is there a way to schedule a SikuliX script to run automatically?

I've managed to run the script from the command line thinking that i could possibly use windows Schedule Task to run it, but it doesn't run command prompt or anything. When i go and check the task it says it completed. Im running windows8. Any help would be appreciated.
You can make a .bat file to execute your sikuli sript. .bat files can be scheduled with Windows 8, but you may need to schedule that task as SYSTEM or as the admin.

DriveImage XML 2008 R2 Task Schedule

I'm attempting to create a scheduled task on two different Windows 2008 R2 Servers that will use Driveimage XML by Runtime Software to create a disk image. The tasks are scheduling fine and running at proper times and after observing the running processes even the dixml.exe shows up in the processes section of the servers task manager under the user account that is specified.
The login used to run the task has administrator credentials as well as the GPO sets to allow admin to elevate an application without prompt.
I've tried writing a batch file for the program and running it which is as follows:
"C:\Program Files (x86)\Runtime Software\DriveImage XML\dixml.exe" /bC /s /c1
/v /t"X:\%date:~10,4%_%date:~4,2%_%date:~7,2%_%~0,3%"
I broke up the above script into two lines of code for easy reading.
This script when manually run either from the cmd or double clicking will properly start the process of the backup. However, when attached as a file to the task scheduler the event 'starts' but the program itself does not begin a back-up.
I've tried converting the batch file into this action:
Start a program: dixml.exe
Arguments: /bC /s /c1 /v /t"X:\%date:~10,4%_%date:~4,2%_%date:~7,2%_%~0,3%"
Start in: C:\Program Files (x86)\Runtime Software\DriveImage XML
According to MS in the 2008 R2 does not recoginze trailing slashes or quotations in their task scheduler so you leave them out.
The second method has the same effect of running the task, the program shows in the process tree and corresponds with the vent viewers PID code, but the back-ups are not made.
Anyone have experience with this perplexing issue?

How do I get Powershell to execute in scheduled task?

I have created a Powershell script and set it up to run within a .bat file. When I click on the .bat file the Powershell script runs like a champ. I then set up the .bat file to be run as a scheduled task. Again it works like a champ when I right click on it and launch it interactively. Problem is it fails when the task scheduled to run unattended in the evening.
Not sure if this matters but I am using Powershell v.1 on Windows 2003 Server 64.
Thanks in advance for your help.
==========================================
The status on the scheduled task is "Could not start". Perhaps fails was the wrong choice of words because the task probably doesn't even start running.
The task is set up to run as my user and I am set up as a local administrator on the box.
Check if scheduled task's security setting
Scheduled task might be running under a credential that does not have access to the batch file.
When you are adding a new task, you are asked to enter a credential
And you can check for already created task's credential
[UPDATE]
The status on the scheduled task is "Could not start". Perhaps fails was the wrong choice of words because the task probably doesn't even start running.
Make sure that Task Scheduler service is running
Is the task set to run with your useraccount or as System? Check the access rights on cmd.exe and powershell.exe.
Also if you go to the sheduled tasks you can do a 'view log' in the advanced menu to check for error messages.
Just a guess, but could it be something to do with the account/security context from which the script is running? If it's running on the System account, then that could certainly be a problem. (I suspect it's just running on your user account however.) Check that all your path variables are set correctly when the script runs, for a start. Otherwise, could you perhaps provide any more information on how exactly it fails (i.e. any error messages)?
Maybe the current directory is not set as you expect when running from the task manager. Try running your bat file from the command line, while you are not in the same directory as the file (and your .ps1 script) are.
Otherwise: check permissions.