Return code of scheduled task prefixed with 0x8007000 in list view, registered as 0 in the event log

后端 未结 2 648
梦如初夏
梦如初夏 2021-01-16 07:52

I am currently trying to setup monitoring of windows scheduled tasks in Zabbix. It seemed easy enough to just monitor the Microsoft-Windows-TaskScheduler/Operational event l

2条回答
  •  误落风尘
    2021-01-16 08:08

    (this is NOT an answer, but StackOverflow is refusing to let me add comments - when I click 'add comment', browser scrolls to top of page :-/)

    You may be misinterpreting the Last Run Result column. According to Wikipedia (http://en.wikipedia.org/wiki/Windows_Task_Scheduler), LRR values of 0, 1 and 10 are common. Ignore the 0x8007 prefix - this just indicates a WIN32 error code transformed into an HRESULT (http://msdn.microsoft.com/en-us/library/gg567305.aspx).

    Try running the test and forcing an exit code of something other than 1 or 10 to see if this influences LRR.

    This does not explain of course why action return code is 0 in 2012. Error code 10 is defined as 'environment is incorrect'. Could it be that 2012 server does not want to run 32bit executable?

    One other suggestion (and I'm a little out of my depth); according to (http://msdn.microsoft.com/en-us/library/system.environment.exit(v=vs.110).aspx): "Exit requires the caller to have permission to call unmanaged code. The return statement does not.". Might be worth re-compiling ExitCodeTest as follows:

    static int Main(string[] args)
        {    
            int exitCode = 0;
            if ( args.Length > 0 )
            {
                exitCode = Convert.ToInt32( args[0] );
            }
            return exitCode;
        }
    

提交回复
热议问题