Link to home
Start Free TrialLog in
Avatar of YZlat
YZlatFlag for United States of America

asked on

How can I use a timer to schedule exe to run at a specific time

I have a windows service that retrieves date and time from the database and then needs to schedule exe to run at that time. Can someone help?
Avatar of jacobstewart
jacobstewart
Flag of United States of America image

Have you tried to create a scheduled task for the exe?
SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of YZlat

ASKER

idle_mind, what is Schedule in this case?
It's at line #1, and is a Dictionary to associate the string path to the EXE with each Timer instance so you can look it up when the Elapsed() event fires.
Avatar of YZlat

ASKER

I tried your code and it seemed to do nothing. So I che4cked the Task manager and saw that the process for the exe was running but the user form didn't show up. My exe is a Windows application
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of YZlat

ASKER

Can I add a windows form to my windows service and run that form instead of an exe?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of YZlat

ASKER

Thanks.
One more thing, if I replace my Windows service with exe, how can make it run every hour programmatically? I want to schedule it either via code or via setup project i use to install it. Is there a way to do that?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of YZlat

ASKER

I tried to schedule the task using Windows scheduler but there is no option for hourly, just daily
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of YZlat

ASKER

Can this be done programmatically?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of YZlat

ASKER

Thank you, I will check it out