Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can VFP schedule a task in Windows 7?

Status
Not open for further replies.

markftwain

Technical User
Jul 12, 2006
108
What is the best way to have a User programatically schedule a task in VFP on Windows 7? I would like to have a single vfp .exe file be scheduled at a time specified by the user. At run time, I would like it to receive the initial parameters it was scheduled with. I have tried every permutation of Schtasks, ShellExecute, and Wsript without success. Additionally, it would be nice to avoid the momentary flash of the cmd window. When using ShellExecute, I can't seem to pass any parameters to SchTasks and Wscript seems hopeless.

Thank You
 
Well, planning Tasks is already quite easy via Scheduled Taks Manager. And indeed an application doing that programmatically needs the same administrative priviliges as you need to schedule a task anyway.

Besides that I googled "vfp schedule task" for you and found:


Bye, Olaf.
 
Hi Olaf,

Thank you for the reference. I missed that one. Unfortunately, it seems to depend on taskManager.dll meant for pre-vista machines. Any idea how to deal with windows 7?
 
See section Task Scheduler 2.0

So you're right, that has changed drastically.

You say "I have tried every permutation of Schtasks, ShellExecute, and Wsript without success."

Can you perhaps post a sample you tried? Is the only difficulty passing in parameters, registering a task with parameters given in foxpro?

The easiest would perhaps be ShellExecuting SchTasks, the 4th parameter of ShellExecute is to pass parameters to the EXE run with ShellExecute, that is toSchTasks.

To pass in parameters to the exe started by the task, you need to set them in the command executed, eg theat command is not only the exe name of the foxpro exe, but you add the parameters there.

Eg take this XML of a scheduled task:

If you modify the command in it from notepad.exe to notepad.exe readme.txt notepad will try to find a readme.txt and if not pops up a dialog asking, if it should create the file.

In your foxpro exe the main.prg must have an lparameters line and you can receive the parameters set within the command of the scheduled task.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top