How to Schedule Website Screenshots with a Windows Task Scheduler Script
Capture a website automatically on a Windows schedule with Playwright and Task Scheduler. Set up paths, accounts, triggers, and checks for reliable runs.
To schedule website screenshots on Windows, write a script that opens the site and saves an image, then use Task Scheduler to run that script on a recurring or one-time trigger. The scheduler controls when the script starts; Playwright controls the browser and screenshot. This guide uses Node.js and Playwright, with explicit paths and a headless browser so the task can run without an interactive desktop.
The example below is a starting point, not a tested end-to-end Windows recipe. Check it against your installed Windows, Node.js, and Playwright versions, then run it manually under the same account and context that will run the scheduled task.
1. Install Playwright and its browser
Install Node.js, create a directory for the capture script, and install Playwright in that directory. Each Playwright version requires matching browser binaries; install them with the Playwright CLI and repeat the install after upgrading Playwright if needed. On Windows, the default browser cache is under %USERPROFILE%\AppData\Local\ms-playwright.
mkdir C:\WebsiteShots
cd C:\WebsiteShots
npm init -y
npm install playwright
npx playwright install chromium
Run the commands in PowerShell or Command Prompt. If your organization manages Node.js or browser installs centrally, follow that setup and make sure the task identity can access the installed files.
2. Create a screenshot script
Save this as C:\WebsiteShots\capture.js. It creates the output directory if necessary, opens the page in headless Chromium, waits for navigation to reach the requested load state, and writes a full-page PNG with a timestamped name. Set the target URL and output directory to values appropriate for your environment.
const fs = require('node:fs/promises');
const path = require('node:path');
const { chromium } = require('playwright');
const targetUrl = process.env.SCREENSHOT_URL || 'https://example.com';
const outputDir = process.env.SCREENSHOT_DIR || 'C:\\WebsiteShots\\output';
async function main() {
await fs.mkdir(outputDir, { recursive: true });
const browser = await chromium.launch({ headless: true });
try {
const page = await browser.newPage({ viewport: { width: 1440, height: 900 } });
await page.goto(targetUrl, { waitUntil: 'load', timeout: 60000 });
await page.screenshot({
path: path.join(outputDir, `site-${new Date().toISOString().replace(/[:.]/g, '-')}.png`),
fullPage: true
});
} finally {
await browser.close();
}
}
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
The script uses load as a straightforward starting condition. Sites that fetch important content after the load event may need a more specific wait, such as waiting for a selector that marks the content as ready. Avoid arbitrary long sleeps where a meaningful page condition is available. fullPage: true captures the scrollable page; omit it for a viewport-only image. Playwright documents navigation and screenshot options in its Page API.
3. Run it manually before scheduling
From the script directory, run the capture with the same URL and output location you intend to use:
cd C:\WebsiteShots
$env:SCREENSHOT_URL = 'https://example.com'
$env:SCREENSHOT_DIR = 'C:\WebsiteShots\output'
node .\capture.js
Confirm that the image exists and looks right. Then check that the script works when launched from a different current directory, because scheduled tasks do not necessarily start in the script directory. The script above uses an absolute output path for that reason.
4. Create a scheduled task
You can use the Task Scheduler graphical interface or schtasks.exe. Microsoft documents these as interchangeable ways to create and manage tasks. In the GUI, create a task, choose a trigger, and set the action to start the Node.js executable with the script as an argument. Set the working directory to C:\WebsiteShots if the task dialog offers a “Start in” field.
For a command-line example, create a daily task at 9:00 AM:
schtasks /create /tn "Website screenshot" /sc daily /st 09:00 /tr "C:\Program Files\nodejs\node.exe C:\WebsiteShots\capture.js"
This illustrates the task name (/tn), schedule type (/sc), start time (/st), and command (/tr). The exact Node.js installation path can differ. If the path contains spaces, quote it correctly as part of the task action; using the GUI can make the program and argument fields easier to configure separately. Do not put an account password directly into a published command. Configure the task’s run identity and credentials through the appropriate Windows task settings for your environment.
Choose a trigger that matches the capture cadence
| Need | Trigger example |
|---|---|
| One capture on a date and time | /sc once /sd MM/DD/YYYY /st HH:MM |
| Every day | /sc daily |
| Selected weekdays | /sc weekly /d MON,WED,FRI |
| At startup or logon | /sc onstart or /sc onlogon |
| At a repeating interval | Use a supported schedule type and modifier such as /mo; check the installed Windows syntax for the interval you need. |
schtasks.exe supports minute, hourly, daily, weekly, monthly, once, startup, logon, idle, and event schedules. Use the simplest trigger that fits the cadence. Microsoft lists the syntax and examples in the schtasks create documentation.
5. Set the run account and browser visibility
Choose the task identity based on file access, browser availability, and whether the site needs an existing interactive session. A task running as a normal user may have access to that user’s files and browser cache, subject to the task’s logon settings. Confirm access to the script, Node.js, Playwright browser binaries, and output directory under that identity.
For an unattended capture, headless mode is usually the intended configuration: no visible browser window is needed. If a visible browser is required for observation, configure the task for the appropriate logged-on user session. Microsoft’s documentation states that the System account has no interactive logon rights, so users cannot see or interact with programs run with system permissions. Do not choose System if the task must show a browser window.
Task Scheduler runs programs when the machine is running. If the computer is off or unavailable at the scheduled time, do not assume a capture will happen then; missed-run behavior depends on task settings. Inspect those settings and verify the actual behavior on the target machine.
6. Check, run, and inspect the task
Query the task definition, run it on demand, and query the result:
schtasks /query /tn "Website screenshot" /v /fo list
schtasks /run /tn "Website screenshot"
schtasks /query /tn "Website screenshot" /v /fo list
Also check the output directory for a newly written file and review the Task Scheduler history or last run result. If the task starts but no file appears, run the script from the task’s configured identity and inspect its working directory, permissions, and error output.
7. Keep captures consistent and reliable
- Use stable paths. Prefer absolute paths for the script and output. Avoid relying on a mapped drive that may not exist in a background logon session.
- Keep the runtime consistent. Pin the Playwright dependency in the project and reinstall matching browser binaries when upgrading it.
- Choose a meaningful readiness condition. A page’s load event may precede client-rendered content. Wait for a known selector when the page has a reliable ready marker.
- Consider page variability. Dynamic ads, rotating content, timestamps, personalization, and animations can change pixels between captures.
- Keep the environment steady for visual comparisons. Playwright notes that screenshots can vary with operating system, browser version, settings, hardware, power source, and headless mode. Use the same environment when comparing images.
- Plan output retention. Timestamped files accumulate. Set an output retention or cleanup policy that matches the storage available to the task account.
- Check machine availability. A local scheduled task depends on the Windows machine being able to run at the scheduled time. Do not treat it as a remote always-on capture service.
There is no universal interval or timeout that fits every site. More frequent captures create more files and more browser activity. Choose a cadence that matches the change you need to observe, and set navigation timeouts based on the target site’s behavior.
8. Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| Task reports success but no screenshot appears | The action used a different working directory, output path, or identity; or the script exited before capture. | Use absolute paths, check the configured account’s write permission, run the script manually as that account, and inspect task history and process output. |
| “The system cannot find the path specified” | The Node.js executable, script, or output path differs from the configured path. | Verify each path in the task action. Quote paths containing spaces and test the exact command interactively. |
| Playwright says an executable or browser is missing | The browser binaries were not installed for the Playwright version or are unavailable to the task account. | Run npx playwright install chromium from the project setup and check the task identity’s browser cache access. Reinstall after a Playwright upgrade if needed. |
| Works manually, fails when scheduled | The task may run under another account, with another current directory, without the user’s environment variables, or outside an interactive session. | Set the task identity deliberately; use explicit paths and configure required environment variables in the task action or script. Test under the scheduled context. |
| Browser window does not appear | Headless mode is enabled, or the task is running without an interactive user session. | For unattended capture, this is expected. For a visible window, use a logged-on interactive account and disable headless mode in the script; do not use the System account for interactive display. |
| Screenshot is blank or missing late-loaded content | The page was captured before the content became ready, or navigation did not reach the expected state. | Check navigation errors and wait for a content-specific selector or another reliable readiness condition before capture. |
| Images look different on different runs | Browser version, OS, settings, hardware, power source, headless mode, or dynamic page content changed. | Keep the capture environment and browser version consistent; reduce animation or dynamic content where appropriate and compare like-for-like captures. |
| No capture ran while the PC was off | The machine was unavailable at trigger time. | Review task settings for missed runs and test the desired behavior. Ensure the machine is available when captures are required. |
9. Or skip the browser setup
For a one-request capture, ScreenshotNeo provides a website screenshot API and MCP server. This cURL request saves a WebP screenshot:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo API documentation for options and setup. Cookie banners are accepted like a visitor and removed along with supported newsletter popups and chat widgets before the shot. Bot checks, blank pages, failed loads, timeouts, and cache hits are never billed, and response headers identify the page verdict and billing status. Its MCP server lets AI agents use take_screenshot, get_page_info, and capture_pdf. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000.
Sign up free for 1,000 screenshots a month, no card required.
10. Frequently asked questions
Can I run a capture only once?
Yes. Use a one-time trigger in Task Scheduler or the schtasks once schedule and provide the date and start time supported by your Windows version.
Will the task run if nobody is logged in?
That depends on the account and task logon configuration. A background task can run without showing a browser, but the System account cannot display an interactive program to a user.
Can I save a viewport screenshot instead of the whole page?
Yes. In the script, remove fullPage: true from the screenshot options to capture the viewport.
Does Task Scheduler capture websites by itself?
No. It starts the program on a schedule. The script or capture service performs browser navigation and creates the image.


