This is a classic issue with scheduled tasks on Windows 10 vs. Windows 11—particularly when running tasks in the background as a user who is not logged in.
Let’s break down why your batch job fails when “Run whether user is logged on or not” is set:
1. Interactive Desktop Apps (like MSPaint)
When you use an interactive app like MSPaint (
mspaint.exe
) in a scheduled task, that process needs an interactive session (i.e., a logged-in desktop). When the user is not logged on, there isn’t a GUI session available. As a result, apps like MSPaint will never launch or just hang in the background.
2. Microsoft Store/WindowsApps Paths
You’re calling MSPaint from the WindowsApps path:
C:\Users\rsmit\AppData\Local\Microsoft\WindowsApps\mspaint.exe
Apps installed this way (Microsoft Store apps) often do not behave well without an interactive session. Additionally, when run as a background scheduled task (with no user logged in), this path might not resolve correctly or may be unavailable.
3. Printing from Background (Services & Permissions)
Background tasks, especially those started as services, often lack access to printers connected to user sessions. Windows isolates hardware resources for security reasons.
Solutions & Workarounds
A. Use Non-GUI Tools to Print
Rather than calling MSPaint, consider a command-line tool that can print an image without requiring a GUI session. Examples:
- Windows Native: Try using
rundll32.exe
or the print
command, but these have major limitations with images.
- Third-Party: Tools like IrfanView (
i_view64.exe /print=...
) or SumatraPDF—both support silent printing through CLI and work well from service context.
Example with IrfanView:
"C:\Program Files\IrfanView\i_view64.exe" "M:\canontest.jpg" /print
IrfanView is free for personal use and is tiny.
B. Update the Task’s “Start in” Directory
Make sure to set the “Start in (optional)” field in your scheduled task’s Action to a local drive and folder that the system account can access (not a network drive unless mapped at system level).
C. Enable "Allow service to interact with desktop" (Not Recommended)
This is legacy, less secure, and blocked on newer Windows versions. Don’t depend on this.
D. Confirm All Paths are Accessible
Double-check
M:\BatchPrint.bat
and
M:\canontest.jpg
are not on a network drive that isn’t mapped when running as a background task. Map them explicitly with
net use
in your batch script if needed.
E. Log Output for Troubleshooting
Redirect the output to a log to diagnose what’s happening:
cmd /c start "" "C:\Users\rsmit\AppData\Local\Microsoft\WindowsApps\mspaint.exe" /p m:\canontest.jpg > c:\temp\printlog.txt 2>&1
Or, better:
Capture environment variables and error output.
Summary Table
Issue | Why it Fails | Solution |
---|
GUI App (MSPaint) in background | Needs logged-in user, doesn’t run headless | Use headless CLI printer |
WindowsApps/Microsoft Store | Path inaccessible without user session | Use classic .exe (IrfanView, etc.) |
Printer not accessible | Printer mapped to user session only | Use system-wide printer, confirm permissions |
Recommended Solution
- Download and install IrfanView.
- Update your batch script to use IrfanView’s print command.
- Test the new script by running the task with “Run whether user is logged on or not”.
If you need an example batch file for this setup, let me know!