Why is my task always running on Windows 2008 Task Scheduler - windows-server-2008

I've a strange problem on a Windows 2008 Server when trying to schedule a task using Windows Task Scheduler.
Basically I've set-up a task to run daily, calling the Internet Explorer program with a Url.
If I run this task manually from the Task Scheduler (as logged on as the administrator) it works fine, by starting the task and ending correctly.
However now I've tried to set the task to run (as administrator) when the user is not logged on.
Everything appears to be set correctly and I've set the administrator password when prompted. But when I try to run the task from the Task Scheduler to ensure it runs as this user, the task starts, but never ends and is always in the "Running state".
Here is the data from the task event log.
Task Scheduler launched action ""C:\Program Files\Internet Explorer\iexplore.exe"" in instance "{}" of task "\Daily Update".
Task Scheduler launched "{}" instance of task "\Daily Update" for user "administrator" .
Task Engine ":SERVERNAME\administrator:Password:" received a message from Task Scheduler service requesting to launch task "\Daily Update" .
Task Scheduler started "{}" instance of the "\Daily Update" task for user "SERVERNAME\administrator".
Task Scheduler launch task "\Daily Update" , instance "C:\Program Files\Internet Explorer\iexplore.exe" with process ID 5020.
Any ideas why this is happening and how I can over come this problem ?

You are calling a URL using Internet Explorer. IE will be opened and will not close itself.
To call a URL on scheduled time, I suggest you to use free scheduling service, which is born to do this job.
If you insist on this method, just replace IE with a .vb file to call your URL:
'begin VBS script code:
Call LogEntry()
Sub LogEntry()
'Force the script to finish on an error.
On Error Resume Next
'Declare variables
Dim objRequest
Dim URL
'The URL link.
URL = "http://www.example.com/?123"
Set objRequest = CreateObject("Microsoft.XMLHTTP")
'Open the HTTP request and pass the URL to the objRequest object
objRequest.open "GET", URL , false
'Send the HTML Request
objRequest.Send
'Set the object to nothing
Set objRequest = Nothing
End Sub
'end VBS script code
[Disclaimer: I'm among ATrigger team. It's a freeware, not commercial purposes.]

Related

WinAppDriver: Unable to connect to the remote server in Local Session

I am attempting to use WinAppDriver to test a classic Windows form control application on a local PC. This test is to run all on the same PC executing the code, not remotely.
However, when attempting to launch the application with WinAppDriver, the following ex occurs:
Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it
I found where, for WinAppDriver, that Windows must be set to "Developer Mode", and I already have that turned on.
Here's the code I have so far, just using the Notepad.exe example for now:
Dim appCapabilities As DesiredCapabilities = New DesiredCapabilities()
appCapabilities.SetCapability("app", "C:\Windows\System32\notepad.exe")
Dim NotepadSession As New WindowsDriver(Of WindowsElement)(New Uri("http://127.0.0.1:4723"), appCapabilities)
The ex is thrown on the third line.
WinAppDriver was not actually running at the time of executing this code. I was incorrectly assuming that it was already running.
Running it beforehand resolved the error completely, and Notepad launched.

How to Run scripts in vm from local machine browser

I am able to execute the vbs files in VM (UFT Installed).Now I want to execute the vbs files in VM from my local machine (UFT Not installed).Can any one please help me how can i connect the QTP in VM from local machine and execute scripts.
I am using below code to connect to ALM/QTP in VM . Its working good because UFT is installed in VM. But in my case i want to host that code and get URL. So that every one from my team can use that scripts from there local machines (without installing UFT).
Dim qtApp
Set qtApp = CreateObject("QuickTest.Application")
If qtApp.launched <> True then
qtApp.Launch
End If
qtApp.Visible = True
If Not qtApp.TDConnection.IsConnected Then
qtplch.TDConnection.connect "QCLink","CERNATECH","EDUTRACKER","kiran.goud","kiran123",true
End If
qtApp.Open "[QualityCenter] Subject\filePath", False
qtApp.Test.Run
qtApp.TDConnection.Disconnect
'Close QTP
qtApp.quit
'Release Object
Set qtApp = Nothing
VBS is always executed locally --> You need to keep this script on the machine where UFT is installed and provide a different way of triggering it remotely....
OR and this is a Big OR with some COM remoting use such a way:
Set qtApp = CreateObject("QuickTest.Application", "NameOfTheMachineWithUFT_Installed")
The only difference is when you create the Automation Object, you tell the system that it should be created on an other machine and not locally.
However this is a High Security Risk and in most Enterprise Networks forbidden.
I would propose a simple wrapper around your script, eposed by a URL or as already suggested, Jenkins

block internet access with Test Complete

Are there any way, to prevent the internet access of the tester application under the test whit Test Complete? I'd like to test the application's reaction of the lost of the internet connection, but I have to perform this whith a CI tool, which means the Test Complete have to block and unblock to connection.
You can do this using WMI directly from a script (see Working With WMI Objects in Scripts) or by executing a PowerShell script (see Running PowerShell Scripts From TestComplete).
For example, see this question to get a sample PS script:
Command/Powershell script to reset a network adapter

SSIS Script Task To FTP Files: Different Behavior on execute in SSMS Job Activity Monitor and manual execute

i have a problem while excecute a ssis package with a script task for ftp transfer files.
While executed by the SQL Servers Job Agent the tranfered files have a zero byte size and are totaly empty. when i execute the package manualy out of the ssis catalog in sql server 2012 it works fine. also with the account of the SQL Job Agent it works.
Localy in my Visual Studio 2012, the package is also transfer the complete file to the ftp site.
The vb code for FTP is pretty simple:
Dim cm As ConnectionManager = Dts.Connections.Add("FTP")
cm.Properties("ServerName").SetValue(cm, Dts.Variables("User::X_exporttargetserver").Value.ToString)
cm.Properties("ServerUserName").SetValue(cm, Dts.Variables("User::X_exportuser").Value.ToString)
cm.Properties("ServerPort").SetValue(cm, "21")
cm.Properties("ChunkSize").SetValue(cm, "1000")
cm.Properties("Retries").SetValue(cm, "1")
ftp.Connect()
Dim files(0) As String
files(0) = Dts.Variables("User::X_exportfilename").Value.ToString
ftp.SendFiles(files, Dts.Variables("User::X_exporttargetfilename").Value.ToString, True, False)
ftp.Close()
Does anybody know if this is a script task issue or is a problem of the sql agent?
Give it a try by setting TimeOut value as,
cm.Properties("Timeout").SetValue(cm, "0") 'The 0 setting will make it not timeout
You can enable logging so that you can get more insight about data while sql agent is executing job.
Just check what's happening during the FTP session using Microsoft Network Monitor
Try it by changing - Creating step in job, choose run as 32-bit mode.
i found the solution for my issue. on the UNC path to the local share i was set the permissions for my user and the sql job agent.
by adding permissions of the ssis service account to this share, the package is execute correctly.

SQL server agent not reporting failure from uncaught exception in PowerShell script

I have set up an SQL server agent job with a few steps that needs to be processed each week. One of which is a PowerShell script that will throw the following (uncaught) custom exception:
$endfile = Test-Path "C:\Temp\1_${loc}_${lastpayweek}.csv"
IF ($endfile -eq $true)
{
throw "target file already exists"
}
Now when this occurs, I can see in the server agent history that an exception was thrown but the step is still reported as a success. Without a failed, the server agent will not send out a notification email to let me know of the failure.
I am calling the PowerShell script like this:
powershell C:\scripts\rename_timesheet_export.ps1 -loc 3
Why is it reported as a success?
You need to set you $ErrorActionPreference to stop:
$ErrorActionPreference = "Stop"
By default this is set to Continue, so when Powershell is called from SQL Agent the job will continue on error unless you change the setting.
I have a few more tips on calling Powershell from SQL Agent here:
http://blogs.technet.com/b/heyscriptingguy/archive/2013/05/06/10-tips-for-the-sql-server-powershell-scripter.aspx
Is this your answer:
Why are my powershell exit codes always "0"?
a lot of things say using -file is the issue but it looks like you aren't