本文介绍了通过ASP.Net编程安排作业失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Windows计算机中创建计划作业.我正在这样做:

I''m trying to create a Scheduled job in windows machine. I am doing this:

private static uint mFnCreateJob(string Command, uint DaysOfMonth, uint DaysOfWeek, bool InteractWithDesktop, bool RunRepeatedly, string StartTime, out uint JobId)
        {
            try
            {
                ManagementBaseObject lObjInputArgs = null;
                ManagementScope lObjScope = new ManagementScope(@"\root\cimv2");
                lObjScope.Connect();
                ManagementClass lObjclassObj = new ManagementClass(lObjScope, new ManagementPath("Win32_ScheduledJob"), null);
                lObjInputArgs = lObjclassObj.GetMethodParameters("Create");
                lObjInputArgs["Command"] = Command;
                lObjInputArgs["DaysOfMonth"] = DaysOfMonth;
                lObjInputArgs["DaysOfWeek"] = DaysOfWeek;
                lObjInputArgs["InteractWithDesktop"] = InteractWithDesktop;
                lObjInputArgs["RunRepeatedly"] = RunRepeatedly;
                lObjInputArgs["StartTime"] = StartTime;
                ManagementBaseObject outParams = lObjclassObj.InvokeMethod("Create", lObjInputArgs, null);
                JobId = ((uint)(outParams.Properties["JobId"].Value));
                return ((uint)(outParams.Properties["ReturnValue"].Value));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }


..并且总是失败. outParams ["ReturnValue"]为2,为null outParams.Properties ["JobId"].Value…类似失败.请对此提出任何建议.
谢谢
Sreenath


..and it always fails. The outParams["ReturnValue "] is 2 and is null outParams.Properties["JobId"].Value…like fails. Any suggestions on this please.
Thanks
Sreenath

推荐答案


这篇关于通过ASP.Net编程安排作业失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 01:53