Solved

Scheduling tasks

Posted on 2004-08-04
8
847 Views
Last Modified: 2012-05-05
Does anyone know how I can make a VB program that will create a scheduled task in windows xp?

I was originally going to just use windows' schtasks command, but I can't figure out how to use that to schedule a command with a switch '/s' at the end.
0
Comment
Question by:Crash2100
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 67

Expert Comment

by:sirbounty
ID: 11716545
What command are you using now?  Can you post the command line?
Should be able to use schtasks from a shell...
0
 
LVL 18

Author Comment

by:Crash2100
ID: 11717654
I've tried several different ways to do this.  Currently I'm trying this with a batch file created by the program, so that I can have a record of what the command executes.  What I really don't understand is why the first batch file I created manually, works just fine, then the one created by my VB program doesn't work.  From what I can tell, they have identical code:

This batch file works:

SCHTASKS /Create /SC Once /ST 22:34:00 /TN MBABackup /s JEFF /ru Jeff /TR "E:\DOCUME~1\Jeff\Desktop\DRSTOL~1\NEWMBA~1\MBABAC~1.EXE /s" /rp

And this one doesn't:

SCHTASKS /Create /SC Once /ST 22:34:00 /TN MBABackup /s JEFF /ru Jeff /TR "E:\DOCUME~1\Jeff\Desktop\DRSTOL~1\NEWMBA~1\MBABAC~1.EXE /s" /rp

And here's the code from my VB program that compiles the line for the batch file:

strPath = "SCHTASKS /Create /SC " & "Once" & " /ST 22:34:00" & " /TN " & "MBABackup"
        strPath = strPath & " /s " & Environ("computername") & " /ru " & Environ("username")
        strPath = strPath & " /TR " & Chr(34) & GetShortPath(App.Path & "\" & App.EXEName & ".exe") & "/s" & Chr(34) & " /rp " & txtPassword
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 11717816
See the task scheduler wrapper at http://www.mvps.org/emorcillo/dotnet/shell/index.shtml
0
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

 
LVL 70

Accepted Solution

by:
Éric Moreau earned 500 total points
ID: 11717822
0
 
LVL 18

Author Comment

by:Crash2100
ID: 11718903
At first I couldn't get that VB6 code to work.  I had to re-create the VB project group, then it all worked perfictly.  Let me mess with the code in it and see if I can get it working in my program the way I want.  This looks very promising.
0
 
LVL 18

Author Comment

by:Crash2100
ID: 11722557
Using that code, is there a way I can edit the properties of the task from within my VB Program?  So I can change things like the day it runs on from my program.
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 11722617
Sure. It will be something like this:

    With m_oSchedule(lstTasks.ListIndex + 1)
        .Triggers.Item(1).MonthlyDOW_DaysOfTheWeek = Saturday
        .Save
    End With
0
 
LVL 18

Author Comment

by:Crash2100
ID: 11741059
It all worked great.  Thanks!
0

Featured Post

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month7 days, 13 hours left to enroll

632 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question