开发者

What's the vbs code to schedule a task every time Windows starts up?

I would like to know how to write up the vbs code to schedule a windows task to start a .exe program every time the Windows starts up.

I found the following code online:

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objNewJob = objWMIService.Get("Win32_ScheduledJob")
errJobCreated = objNewJob.Create _
    ("Notepad.exe", "********123000.000000-420", _
        True , 1 OR 4 OR 16, , , JobID) 
Wscript.Echo errJobCreated

But it only tells me how to schedule the task every on some specific days and hours.

I thought of creating a windows service. However the following is the story why I must look for an alternative to it.

I created a windows service with RunAsService for my java program wrapped with Janel. The Service worked fine when I first installed and started it. However, after restarting my windows xp, a dialog window poped out saying that my janel generated .exe file has crashed, with my RunAsService service kept on going. The service worked fine when I terminated the service and restarted it again m开发者_如何学JAVAanually. Nevertheless, the same crash happens over and over again every time I restart my Windows.


Would it not be easier just to put a shortcut to your application in the Startup folder???

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜