I want to run Exe after 1 minute when computer starts
Means suppose comp starts at 10:00:00 pm my exe automatically executes at 10:01:00pm
How to do it through program??
Two practical, reliable options beyond a simple hard sleep were suggested by and . The approach below expands on those ideas with production-ready choices, pitfalls to watch for, and a small, safe C++ example you can drop into a lightweight startup launcher.
Use Task Scheduler when you want reliability and control. Create a task with the trigger "At startup" and use the trigger's Advanced Settings -> "Delay task for" = 1 minute. Tasks can run as SYSTEM or a specified account, run whether a user is logged on or not, and provide history for debugging. For automation or scripting, use the Task Scheduler API or the command-line tool. See the Task Scheduler overview and schtasks reference for details:
Task Scheduler start page
schtasks command reference
If you prefer a small program in the Startup folder, avoid blocking the thread with a crude sleep. Instead, check how long the system has been up and set a waitable timer for the remaining interval. This keeps the process responsive and avoids long, unconditional sleeps if the machine has already been up for a while. Example (Windows API):
// compute milliseconds since boot
unsigned long long uptimeMs = GetTickCount64();
const unsigned long long delayMs = 60ULL * 1000ULL;
if (uptimeMs < delayMs) {
DWORD toWait = (DWORD)(delayMs - uptimeMs);
HANDLE hTimer = CreateWaitableTimer(NULL, TRUE, NULL);
if (hTimer) {
LARGE_INTEGER li;
li.QuadPart = -((LONGLONG)toWait * 10000); // relative time in 100-ns units
if (SetWaitableTimer(hTimer, &li, 0, NULL, NULL, FALSE))
WaitForSingleObject(hTimer, INFINITE);
CloseHandle(hTimer);
}
} If the program must run as a background service, consider registering a Windows service and using "Automatic (Delayed Start)". For debugging, check Task Scheduler history or the Event Viewer, ensure correct account/paths, and remember network resources may not be available immediately after boot.
Jump to Post— Black Magic 15I guess you could drag your program into startup.
To wait one minute use :
#include <windows.h> int main() { Sleep(60000); // Sleep (Wait) for one minute }
I guess you could drag your program into startup.
To wait one minute use :
#include <windows.h>
int main()
{
Sleep(60000); // Sleep (Wait) for one minute
} You're playing with deep stuff.
Google "msdn task scheduler and take a look at the task scheduler scripting objects and interfaces (depending on how you want to do it).
You'll need admin rights to do it.
Hope this helps.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.