计划任务无法在某些win7计算机上触发 [英] Scheduled Task fails to trigger at some win7 machines

查看:289
本文介绍了计划任务无法在某些win7计算机上触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Windows应用程序,我已经创建了一个Windows服务和任务来满足我的应用程序的目的。



正在使用OnlogonTrigger创建任务true和它启动我的应用程序(.exe),它位于system32文件夹中。



该应用程序是用C#dot net framework 2.0构建的。我的应用程序是使用WIX安装的。



我在LogonTrigger创建任务,以便每次有人登录到该系统时都会调用我的任务。 />


我已经使用(TaskScheduler.dll)编写代码来在我的服务的OnStart方法中创建ScheduledTasks。正在创建服务和任务。以下代码供您参考。



I have a windows application where I have created a windows service and Task to serve the purpose of my application.

The task is being created with OnlogonTrigger true and it starts my application (.exe) which is inside the system32 folder.

The application is built in C# dot net framework 2.0 . My application is installed using WIX.

I am creating the task at LogonTrigger so that my task is being called at every time when some one logged into that system.

I have written the code using (TaskScheduler.dll) to create ScheduledTasks at the OnStart method of my service. The service as well as the Task are getting created. The below code is for your reference.

ScheduledTasks ts = new ScheduledTasks();
string taskName = "myTaskName";
Task td = null;

protected override void OnStart(string[] args)
{
    string getFullPath = '';
    getFullPath = "*****************"; //Full path of the file
    try
    {
        td = ts.OpenTask(myTaskName);
        if (td == null)
        {
            td = ts.CreateTask(myTaskName);
            td.ApplicationName = getFullPath;
            td.Comment = "eWatch for user PC";
            string acct = GetProcessOwner("explorer.exe");
            td.Flags = TaskFlags.RunOnlyIfLoggedOn | TaskFlags.Hidden;
            td.SetAccountInformation(acct, (string)null);
            td.Triggers.Add(new OnLogonTrigger());
            td.Save();
        }
        td.Close();
        ts.Dispose();
        }
        catch (Exception ex)
        {

        }
}





我已经在某些计算机上安装了我的Win7设置并检查了每台机器上是否创建了任务但是在某些计算机上无法运行一个登录到系统。



我确信任务是在每台机器上创建的,因为我在调用OnStart方法时转储了一个文件。甚至我已经在这个文件上写了一些文本,而每一行都执行了。安装完成后,我检查了文件,发现所有的行都写得很完美;但当有人登录这些机器时,我的任务无法触发,我的设置(.exe)也没有被启动/调用。



然后我卸载了这个应用程序并使用ScheduledTasks.DeleteTask(myTaskName)删除了我在我的服务的OnStop方法中编写的任务。以下代码供您参考。





I have installed my set up with Win7 at some computers and checked that the Task is created at every machine but fails to run in a few when some one logged into the system.

I am sure that the task is created at every machine because I have dumped a file when OnStart method is being called. Even I have written some text at this file while each an every line is executed. After installation, I have checked the file and found that all the lines are perfectly written; but when some one logged into those machines, my Task fails to trigger and my set up(.exe) is also not being started / called.

Then I have uninstalled this application and deleted the Task using ScheduledTasks.DeleteTask("myTaskName") which I have written at OnStop method of my service. The below code is for your reference.

protected override void OnStop()
   {

       try
       {
           td.Close();
           td.Dispose();
           // Remove the task we just created
           ts.DeleteTask(taskName);
           ts.Dispose();

       }
       catch (Exception ex)
       {

       }
   }





但是上面的代码无法删除任务,当我再次安装设置时,控件不会插入上面的OnStart方法的IF块内。我的转储文件也证明了我的上述评论。



我无法理解为什么我的任务没有在那些WIN7机器中被触发时有些人登录到那些WIN7机器,但同样的设置正在一些WIN7机器上工作。



我真的很困惑为什么我的任务不能正常工作。



请在这方面帮助我。



任何形式的帮助都将受到高度赞赏。



But the above code is not able to delete the task and when I have again installed the set up , the control does not insert inside the IF block of OnStart method above. My dump file is also the proof of my above comment.

I can't understand why my Task is not getting triggered in those WIN7 machines when some one Logged into those WIN7 machines, but this same set up is working at some WIN7 machines.

I really confused why my Task is not working what it is supposed to do.

Please help me in this regard.

Any kind of help will be highly appreciated.

推荐答案

与任何问题一样,您需要更多数据。我的第一个建议是了解用户问题或机器问题。



开始收集有关成功运行的信息与不成功运行的信息 - 一个重要数据要点是为用户确定用户帐户类型(admin或standard?),并在此处存在问题。 (通常,它是权限的东西。)



基于机器的问题有点复杂 - 不同的操作系统补丁级别,DOMAIN -vs-非域加入的机器,组策略设置,.NET版本,目录上的ACLS以及运行登录批处理作业。这个列表相当长,可以参与其中。



一次吃一口。
As with any problem, you need more data. My first suggestion would be to get an understanding if its a USER problem or a MACHINE problem.

Start collecting information about the successful runs versus the unsuccessful ones - an important data point is determining user account type (admin or standard?) for users and correlate if there are issues here. (Usually, it's a permissions thing.)

Machine based issues are a bit more complex - disparate OS patch levels, DOMAIN -vs- non-domain joined machines, group policy settings, .NET version, ACLS on directories and if login batch jobs run. The list is fairly long here and can get involved.

Take a bite at a time.


这篇关于计划任务无法在某些win7计算机上触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆