Windows Task Scheduler - Last Run Time and Last Run Result - c#

We have several scheduled jobs running in our various servers. I was looking if I could do something to see all the scheduled tasks along with the last run time and the last run result.
I have looked at this CodeProject article but I couldn't find anything for the last run details.
Also, I have looked at the XML file located at
C:\Windows\System32\Tasks
Using this file I can get the jobs but not the last run details.
I would like to know how I should proceed to get the jobs along with their last run details from remote computers.

You might want to try the managed wrapper for the scheduler API: http://taskscheduler.codeplex.com/
Project is migrated to https://github.com/dahall/taskscheduler

From this 2015 blog post, you can get this data running this PowerShell command:
Get-ScheduledTask | where state -EQ 'ready' | Get-ScheduledTaskInfo | Export-Csv -NoTypeInformation -Path C:\scheduledTasksResults.csv
The result will be on a CSV file, which you can open with Excel and export it as the bellow table:
LastRunTime | LastTaskResult | NextRunTime | ...
21-12-17 20:24 | 0 | 0 | ...
15-05-18 | 12:55 | 0 | ...
14-05-18 19:13 | 0 | 0 | ...
14-05-18 | 19:14 | 0 | ...
30-11-99 01:00 | 267011 | 0 | ...
15-05-18 12:25 | 0 | 16-05-18 | ...
14-05-18 19:13 | 2147500037 | 0 | ...
15-05-18 | 14:15 | 0 | ...
14-05-18 | 19:15 | 0 | ...
15-05-18 | 12:25 | 0 | ...
__
Related with:
Get last run date of task in Windows Scheduled Tasks from ASP.NET

Related

Stryker can't find .csproj file even though it's passed in command

When I try to run Stryker with the below command it fails saying it can't find a .csproj file. The file exists at the configured location though:
C:\Users\Me\Documents\git\my_pkg>dotnet stryker --solution-path ".\My.Project.sln" --test-runner DotnetTest --project-file ".\test\My.Project.Tests\My.Project.Tests.csproj"
_____ _ _ _ _ ______ _______
/ ____| | | | | \ | | ____|__ __|
| (___ | |_ _ __ _ _| | _____ _ __ | \| | |__ | |
\___ \| __| '__| | | | |/ / _ \ '__| | . ` | __| | |
____) | |_| | | |_| | < __/ | | |\ | |____ | |
|_____/ \__|_| \__, |_|\_\___|_| (_)|_| \_|______| |_|
__/ |
|___/
Version: 0.20.0 (beta)
[10:41:49 INF] Time Elapsed 00:00:00.8016192
Stryker.NET failed to mutate your project. For more information see the logs below:
No .csproj file found, please check your project directory at C:\Users\Me\Documents\git\my_pkg
Why is the file not found?
--project-file should point to the project you intend to mutate, not the unit test project. That is, if My.Project.csproj is the project you are testing and My.Project.Tests.csproj are the accompanying unit tests, then what I would normally do is navigate to the folder containing the My.Project.Tests.csproj and run dotnet stryker from the command line. If there is only one project reference in the My.Project.Tests.csproj it will be automatically detected and Stryker will attempt to create mutants to check your Unit Test project. If there are multiple project references in the My.Project.Tests.csproj file, then you will be asked to clarify which project you intend to mutate by passing the --project-file.
Personally I would create a stryker-config.json in the root of your unit testing project, as shown here: https://github.com/stryker-mutator/stryker-net/blob/master/docs/Configuration.md
You probably want something like this:
{
"stryker-config": {
"reporters": [
"progress",
"html"
],
"log-level": "info",
"log-file": true,
"timeout-ms": 10000,
"project-file": "My.Project.csproj",
"max-concurrent-test-runners": 4,
"threshold-high": 80,
"threshold-low": 70,
"threshold-break": 60,
"mutation-level": "Standard",
"excluded-mutations": [
"string"
],
"dashboard-compare": false
}
}
Assuming My.Project.csproj is referenced in your unit test project.

How can i get the size of every db on my PostgreSQL server

I need to get size of every table and every database on my PostgreSQL server in my c# console app.
I am using npgsql for server connection,and i`ve found script for table part
SELECT table_schema AS \"Database\",
SUM(data_length + index_length) / 1024 / 1024 AS \"Size(MB)\"
FROM information_schema.TABLES
GROUP BY table_schema
but still i can`t switch databases. How can i connect to different databases on my server without knowing their names.
Make use of system information functions:
https://www.postgresql.org/docs/current/functions-admin.html
For database sizes:
select datname, pg_size_pretty(pg_database_size(datname)) from pg_database ;
datname | pg_size_pretty
------------------------+----------------
my_test_db | 7865 kB
production | 64 MB
no_public_sch_template | 7857 kB
test | 11 MB
test_gz | 9681 kB
sch_test | 7857 kB
template0 | 7713 kB
task_manager | 9681 kB
template1 | 7865 kB
aquaculture | 15 MB
track_stocks | 9425 kB
track_stocks_test | 9529 kB
postgres | 8273 kB
From pg_database you can get the database name(datname) for building a script to iterate over for the tables.

OpenQA.Selenium.WebDriverException: Unexpected error. session does not exist

I have the following specflow test that passed if i run it independently however when i run it in a suite i get the following error when i reaches the table:
OpenQA.Selenium.WebDriverException: Unexpected error. session
82486589-6a16-4b60-9503-c25a886698e7 does not exist
Here is example of the Specflow Scenario:
Scenario: New Register user
Given I Navigate to 'https://somewebsite.com/'
And Click element with link text 'Register'
And I wait for '5' seconds
When Enter the following new user details:
| Username | Password | Email | Firstname | Lastname | Time Zone |
| Bobby | password99 | some#email.com | Bob | smith | GMT ------ U.K. |
And I take a screenshot and save it as 'SmartBear new user information' in 'C:\AutomationScreenShots'
And I click 'Register' button*
Any help will be gratefully appreciated

How to create a special docked window outside of the desktop (like microsoft test manager)

When using the Test Runner of Microsoft Test Manager, it creates a window which is docked to the edge of the screen. This window seems to sit "outside" the desktop area so that the start menu, etc don't overlap it, and when you maxmize another app, it takes up the remainder of the screen and this docked window stays in place.
Some Ascii art to explain
Normal windows Desktop
+-------------------------------------------------+
| |
| Icon |
| Icon |
| Icon |
| |
| |
| |
+-------------------------------------------------+
| start <taskbar> 2pm |
+-------------------------------------------------+
With MTM runner
+----------+--------------------------------------+
| | |
| | Icon |
| | Icon |
| MTM | Icon |
| Runner | |
| special | |
| window | |
+ |--------------------------------------+
| | start <taskbar> 2pm |
+----------+--------------------------------------+
I'd like to do something similar to this in my application, but I can't figure out what to google for or what the terms might be. The app is a C# WPF app, but I'm happy to P/Invoke into C or C++ if neccessary.

Is it possible to call specific msconfig tab?

I need to know that is it possible to call specific tab of System Configuration through c# application.
Till now I am only able to call msconfig.exe through my code i.e.
ProcessStartInfo pf = new ProcessStartInfo(
Path.Combine(Environment.SystemDirectory, "msconfig.exe"));
pf.Verb = "runas";
Process.Start(pf);
Now I want to call only Single tab to open that is StartUp at button click.
Please get me some solution.
Msconfig takes a number as argument to decide which tab to show. -4 is the StartUp Tab
ProcessStartInfo pf = new ProcessStartInfo(
Path.Combine(Environment.SystemDirectory, "msconfig.exe"));
pf.Verb = "runas";
pf.Arguments ="-4";
Process.Start(pf);
+--------------------+
| Arg | Tab |
+--------------------+
| -1 | General |
| -2 | Boot |
| -3 | Services |
| -4 | Startup |
| -5 | Tools |
+--------------------+
blog with the arguments No formal docs from microsoft seem to exist with regard to this argument. This works for me on Windows7.

Categories