Solved

Scheduling tasks

Posted on 2004-08-04
8
839 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

739 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