Thank you for being a valued part of the CNET community. As of December 1, 2020, the forums are in read-only format. In early 2021, CNET Forums will no longer be available. We are grateful for the participation and advice you have provided to one another over the years.

Thanks,

CNET Support

General discussion

Batch files to run a program only if the time is >8:00

Jun 26, 2013 4:10AM PDT

Hi friends, i need to write a batch files to run a .exe files only if the hour of the day is greather than 8:00.

So..i run a .bat files with task scheduler every 5 minute whit the command "start" and then if the hour of the day is greather than 8:00 the program start.if not the program don't start..

Example.. if i have a task scheduler setting to start Notepad.exe at 8:00 and i turn on my pc at 8:05 this task don't start...and i think to need a batch files running via task scheduler every minutes to check the time and then run the notepad .exe if the condiction is ok.

Sorry for my bad explication but english is not my language..
Thank you very mutch.
Luke.

Discussion is locked

- Collapse -
Just checking.
Jun 26, 2013 4:18AM PDT
- Collapse -
I checked...
Jun 26, 2013 4:43AM PDT

Hi..
I checked " run as soon as possible..."

So now i try to miss a trigger time..turning on my pc at 8:10 and the "notepad.exe" in theory must start..
I post the result as soon...

Luke.

- Collapse -
Sorry but I gotta ask.
Jun 26, 2013 5:06AM PDT

If the user is not logged on, why must it start? Where would it display?

- Collapse -
I checked...
Jun 27, 2013 1:16AM PDT

Hi..
I checked " run as soon as possible..."
And "Run whether user is logged on or not",
But still not working for me.
Maybe i miss or don't fully understand the philosopy of this task scheduler.

Thank you.
Luke.

- Collapse -
Not philosophy.
Jun 27, 2013 1:25AM PDT

I asked you a question to draw out what you knew about this area. For example what would you expect to happen if the user was not logged in?

I would expect the launch of notepad to fail. I can't hold a class on this OS here but when you go this deep you would have to get a grasp of the basics and more.

So far, as presented I see nothing wrong.
Bob

- Collapse -
Not philosophy.
Jun 27, 2013 1:52AM PDT

Hi dear friends...

Now i tell the true..
I have my home server "headless" i manage only with remote desktop...The OS is windows server 2008 R2.

I need to start a program at 8:00 if the server is ON....but if i turn ON the server at 8:10 i miss the task scheduler..and the software is OFF...

But i can't put this program to start automatically at "machine on" because if turn on the server at 6:00 i don't need this program running.

Normally the server when is on is without a user logged on, except when i manage whit remote desktop..
So i think on the task scheduler have to check the box "Run whether user is logged on or not".

And i think i need a script to check the hour of the day to decide if the software can start or not and run this script every minute or two...this is my idea..

CiAo

- Collapse -
Writing your own app may be better.
Jun 27, 2013 1:57AM PDT

But let's clear something up. You used NOTEPAD as your example and since that's an interactive app with a logged in user this is not something you would expect to find in Task Scheduler.

Once in a while you find a member not sharing exactly what they are doing and it fails to yield a good answer since they were not sharing exactly what they wanted to do. That is, it wasn't NOTEPAD at all.

There's more to this such as an app may have a dependency. Even NOTEPAD has dependencies and since that word (dependency) is covered in the class work I don't cover that chapter here.

I don't mind discussing this area but it feels as if there is more to this story.
Bob

- Collapse -
Writing your own app may be better.
Jun 27, 2013 2:13AM PDT

Hi...

Really the app is emule..and i'm trying to manage it to work only in a certain hour without depend the hour of the day i turn on the server....

Luke.

- Collapse -
It's a shame that was not revealed up front.
Jun 27, 2013 2:18AM PDT

Because NOTEPAD must interact with the user desktop there are fine reasons it may not launch.

Just some parting advice. Don't obfuscate a discussion. Otherwise you may not get the answer you wanted.
Bob

- Collapse -
Ok..
Jun 27, 2013 2:23AM PDT

Hi Bob..
sorry for "obfuscate" a discussion..really my mistake, but i generalize about the software only because is a simple .exe and i think the answer may be good for other user..

Thank you.
Luke.

- Collapse -
NOTEPAD is not a simple exe.
Jun 27, 2013 2:26AM PDT

As this discussion has run its course and we know that apps like NOTEPAD have dependencies and need an user to be logged on and well, a short list of requirements for it to launch, it's a bit late to start again on some other app.

Why would you think these are simple executable apps is a mystery but I'm sure you will catch up soon.

Sorry but I was mislead on what you wanted to do and can only wish you the best.
Bob