如题

解决方案 »

  1.   

    ITask接口是.net提供的,VB6不能引用,不过可以声明mstask.dll中的函数,比如NetrJobEnum、NetrJobAdd、NetrJobDel等。
      

  2.   

    mstask的函数一直没研究过,任务计划有时候使用条件比较麻烦
      

  3.   


    晕哦,那不知微软自己的schtasks.exe是怎么实现这些功能的哦:)
      

  4.   

    Schedule Functions
    The schedule service functions are used to submit and manage jobs to be executed at a specifed computer at a specified time (or times) in the future. Jobs can be commands and programs. Jobs can be managed at remote and local computers, provided schedule service is running at a specified computer. The schedule service functions are:NetScheduleJobAdd 
    NetScheduleJobDel 
    NetScheduleJobEnum 
    NetScheduleJobGetInfo Schedule service functions are also known as "Job" and "AT command" functions.Schedule service functions are job submittal (NetScheduleJobAdd), job cancellation (NetScheduleJobDel), job enumeration (NetScheduleJobEnum) and retrieving information about a particular job (NetScheduleJobGetInfo). In order for these functions to succeed, a caller must have administrator's privilege at a computer where Schedule service is running.Structures
    The AT_INFO structure is used by NetScheduleJobAdd to specify a job to be added, and by NetScheduleJobGetInfo to return information about an already submitted job. The AT_ENUM structure is used by NetScheduleJobEnum to enumerate and return information about an entire queue of already submitted jobs. 
      

  5.   

    我问的不是NetScheduleJobAdd这些API啊,这些可设置的选项很少.
      

  6.   

    谢谢楼上有两位给的答案,这两个也是在网上比较容易找到一些的,但不适合我需要啊.
    毕竟我这个不是.net为主的项目,.net的方式肯定不是首先.后来搜到这位高人给出的VC6的例子,下载后测试通过,但悲哀地发现:
    这个由C:\WINDOWS\system32\mstask.dll提供的接口,我竟然不知道能否在VB6中直接使用,怎么使用:
    ITask\=>IScheduledWorkItem=>IUnknown
    直接引用肯定是不行的:http://www.codeproject.com/kb/shell/cscheduledtask.aspx
    Basic class for using the Microsoft Task Scheduler
    Mike was a VC MVP from 2005 to 2009.
    Occupation:  Software Developer (Senior)
    Company:  VMware
      

  7.   

    一定要使用ITask吗?如果不使用,微软网站上倒有一篇新建、删除、查看任务计划的贴子,地址:http://www.microsoft.com/china/technet/community/scriptcenter/schedule/default.mspx
      

  8.   

    我觉得这个东西主要看是要多和用户沟通,分析有哪些类型的需求,然后怎么统一规划,在软件中去实现他们.比如有些用户想要桌面有提示"离考研还有多少天"的功能.一步步来吧,首先用这个调用windows自带的任务计划管理界面实现一部分功能:Private Sub OpenTaskScheduler()
            Shell "cmd.exe /c %SystemRoot%\explorer.exe   ::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\::{21EC2020-3AEA-1069-A2DD-08002B30309D}\::{D6277990-4C6A-11CF-8D87-00AA0060F5BF} "
    End Sub不过此时我想到一个安全问题,有经验的人不妨指点一下:
    就是,打开Task Scheduler服务后,默认从网络上好像是可用at命令远程在自己机器上创建服务的是吧.这会不会给从网络上攻击的人提供方便之门.当然,我知at远程创建任务是要用户名密码的,可毕竟现在很多机器上是不设口令,或口令容易猜的啊.
    我从两个方面考虑的:
    一,要测试一下没设口令的机器能否用at远程创建任务
    二,看看怎么设置,使得只允许本机的程序操作任务,不让网络上的程序来尝试枚举密码什么的.