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

血红的双手。 提交于 2019-12-01 12:54:00

(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;
    }

I'm seeing a similar issue on Server 2012 with a batch file that looks like it succeeds, shows a return value of 0 in event log, but a Last Run Result of 0x80070001.

I see MSFT has a hotfix available for Server 2012 which might address this issue:

http://support.microsoft.com/kb/3003689

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!