rsmith0399

New Member
Joined
Jun 25, 2025
Messages
2
I have a batch job that runs every other day to print a test pattern to keep the printer from drying out.
It always worked on Windows 10, but does not work on Windows 11 Pro.

If I check 'Run only when user is logged on' it works fine.
If I check 'Run whether user is logged on or not', it starts, never ends, and never prints anything. When this is checked, the password is stored.

This is an admin account, as it was on Windows 10. It seems to have all the permissions it needs.
Any ideas?
 

Attachments

  • Screenshot 1.webp
    Screenshot 1.webp
    14.1 KB · Views: 0
  • Screenshot2.webp
    Screenshot2.webp
    23.1 KB · Views: 0
  • Screenshot3.webp
    Screenshot3.webp
    7.2 KB · Views: 0
Solution
Your issue with the batch job not working when set to "Run whether user is logged on or not" on Windows 11 Pro, despite working on Windows 10, is a known scenario that can happen due to how Windows handles user sessions and permissions differently in Windows 11.
Here are some ideas and troubleshooting steps:
  1. Interactive Session Dependencies:
    When "Run whether user is logged on or not" is selected, the task runs in a non-interactive session. Printing operations sometimes require an interactive user session or access to the user's profile and printer drivers in a session context. This might cause the job to hang or fail to print.
  2. Printer Access and Drivers:
    Ensure the printer drivers are installed for all users or at...
Your issue with the batch job not working when set to "Run whether user is logged on or not" on Windows 11 Pro, despite working on Windows 10, is a known scenario that can happen due to how Windows handles user sessions and permissions differently in Windows 11.
Here are some ideas and troubleshooting steps:
  1. Interactive Session Dependencies:
    When "Run whether user is logged on or not" is selected, the task runs in a non-interactive session. Printing operations sometimes require an interactive user session or access to the user's profile and printer drivers in a session context. This might cause the job to hang or fail to print.
  2. Printer Access and Drivers:
    Ensure the printer drivers are installed for all users or at the system level, not just the logged-in user's profile. Also, the printer should be accessible to the SYSTEM or the user account running the task in a non-interactive session.
  3. Task Scheduler Settings:
    • In Task Scheduler, check "Run with highest privileges".
    • Verify the user account used has the correct permissions to access the printer and execute batched printing commands.
  4. Network Printers and Credentials:
    If your printer is networked, the stored credentials in the batch job might not suffice in a non-interactive session. Mapping network printers or drives may fail if the session lacks proper network credentials.
  5. Use a Service or Script Alternative:
    Sometimes, running printing commands in a scheduled task under a user session is problematic. Consider using a Windows service or a script running as a service to handle the print jobs, avoiding session issues.
  6. Logging and Diagnostics:
    Add logging to your batch script to confirm it starts and reaches the printing commands when running without the user logged on. Check the event logs for any errors related to printing or task scheduling.
If you'd like, I can help you with specific command-line tweaks or script logging enhancements for diagnosing the problem. Also, I found a thread on Windows Forum describing a similar problem; it might have useful tips tailored to Windows 11 transitions. Would you like a summary of that?
 

Solution
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

IssueWhy it FailsSolution
GUI App (MSPaint) in backgroundNeeds logged-in user, doesn’t run headlessUse headless CLI printer
WindowsApps/Microsoft StorePath inaccessible without user sessionUse classic .exe (IrfanView, etc.)
Printer not accessiblePrinter mapped to user session onlyUse system-wide printer, confirm permissions

Recommended Solution

  1. Download and install IrfanView.
  2. Update your batch script to use IrfanView’s print command.
  3. 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!
 

Your issue with the batch job not working when set to "Run whether user is logged on or not" on Windows 11 Pro, despite working on Windows 10, is a known scenario that can happen due to how Windows handles user sessions and permissions differently in Windows 11.
Here are some ideas and troubleshooting steps:
  1. Interactive Session Dependencies:
    When "Run whether user is logged on or not" is selected, the task runs in a non-interactive session. Printing operations sometimes require an interactive user session or access to the user's profile and printer drivers in a session context. This might cause the job to hang or fail to print.
  2. Printer Access and Drivers:
    Ensure the printer drivers are installed for all users or at the system level, not just the logged-in user's profile. Also, the printer should be accessible to the SYSTEM or the user account running the task in a non-interactive session.
  3. Task Scheduler Settings:
    • In Task Scheduler, check "Run with highest privileges".
    • Verify the user account used has the correct permissions to access the printer and execute batched printing commands.
  4. Network Printers and Credentials:
    If your printer is networked, the stored credentials in the batch job might not suffice in a non-interactive session. Mapping network printers or drives may fail if the session lacks proper network credentials.
  5. Use a Service or Script Alternative:
    Sometimes, running printing commands in a scheduled task under a user session is problematic. Consider using a Windows service or a script running as a service to handle the print jobs, avoiding session issues.
  6. Logging and Diagnostics:
    Add logging to your batch script to confirm it starts and reaches the printing commands when running without the user logged on. Check the event logs for any errors related to printing or task scheduling.
If you'd like, I can help you with specific command-line tweaks or script logging enhancements for diagnosing the problem. Also, I found a thread on Windows Forum describing a similar problem; it might have useful tips tailored to Windows 11 transitions. Would you like a summary of that?
yes please
 

It looks like none of the search results directly discuss printing tasks or batch file scheduled print jobs specifically for Windows 11, but I can give a condensed expert summary of Windows forum wisdom for batch/scheduled printing problems in recent Windows versions, especially based on similar Task Scheduler and automation topics in the forum archive:

Key Community Diagnoses for Similar Issues​

  1. Non-Interactive Session Limitations
    • When "Run whether user is logged on or not" is set, your script runs in session 0, which is non-interactive. Many GUI apps, like MSPaint or other image viewers, do not function in this mode. The printing subsystem may also have trouble accessing user printers outside of their user session.
  2. Path and Printer Access
    • Batch scripts (and the apps they launch) should use absolute paths. Mapped drives (like M:) may not exist for the scheduled task unless you explicitly map them in the batch file at runtime.
    • Network printers added in user context are often not available to system/session 0 tasks.
  3. Privileges and Environment
    • Even with "Run with highest privileges," scheduled tasks outside of an interactive logon may not see user printers, user-profile-installed apps, or certain environment variables.
  4. Script Compatibility
    • Batch files that work at a cmd prompt or in a logged-on session may behave differently under Task Scheduler. Printing, in particular, is heavily session-dependent.

General Troubleshooting Wisdom​

  • Logging: Add lines to your batch file that log progress or errors to a file. This can reveal where the script fails or hangs.
  • Avoid GUI Tools: Avoid MSPaint or other GUI-based printing in non-interactive scheduled tasks. Use command-line or service-friendly tools (see solution below).
  • Network Resources: If you absolutely need a mapped drive, add a net use command at the start of your batch with credentials.
  • Force System-wide Printer: Make sure the printer is installed for all users (sometimes installing as administrator helps).

Community Solutions​

Switch to Headless Printing Tools
Use a command-line image viewer or printer utility for printing instead of MSPaint. For example:
  • IrfanView with i_view64.exe image.jpg /print
  • PowerShell or VBScript to print directly if possible
Example Print Script with IrfanView:
"C:\Program Files\IrfanView\i_view64.exe" "M:\canontest.jpg" /print
This tool works well from both interactive and non-interactive sessions.
Logging Example:
Code:
echo %date% %time% > M:\print.log
"C:\Program Files\IrfanView\i_view64.exe" "M:\canontest.jpg" /print >> M:\print.log 2>&1
echo Finished >> M:\print.log

If Sticking With MSPaint​

You’d need to ensure the script runs only as a logged-in user (using the "Run only when user is logged on" setting), as launching and using the GUI is not reliable headless. This matches your observed results.

TL;DR:
  • The root issue is that printing via GUI automation can't run "headless" (no user session), by design, on modern Windows (including 10/11).
  • Use non-GUI, true command-line printing tools in your scheduled tasks, especially for unattended/server-like operation.
  • Add plenty of logging to confirm path/printer access if needed.
  • If you want forum-thread-level detail on Windows 11-specific print automation, let me know and I’ll dig even deeper!
Let me know if you want an example script for your case or additional step-by-step troubleshooting specific to your batch/print scenario.
 

Back
Top