通过ASP.Net编程安排作业失败

编程入门 行业动态 更新时间:2024-10-26 12:21:23
本文介绍了通过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

推荐答案

您应该阅读Win32_ScheduledJob类,特别是其创建方法 [ ^ ]及其返回值"部分.您得到的返回值为2,这意味着运行代码的用户(ASPNET用户帐户或ISR_USER(?))没有创建计划作业的权限. 您的ASP.NET代码所运行的帐户需要具有对%SystemRoot%\ system32 \ Tasks文件夹的读/写权限. You should read up on the Win32_ScheduledJob class, specifically, its Create method[^] and its Return Value section. The return value you got was 2, which means the user running the code (the ASPNET user account or ISR_USER (?)) does not have permissions to create scheduled jobs. The account your ASP.NET code is running under needs to have read/write permissions to the %SystemRoot%\system32\Tasks folder.

更多推荐

通过ASP.Net编程安排作业失败

本文发布于:2023-11-24 08:46:20,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1624524.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:作业   ASP   Net

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!