How to Force Windows Task Scheduler to Run Console Applications in Visible Mode (Not Hidden)


2 views

Many developers upgrading from Windows Server 2003 to 2008/R2 encountered an unexpected behavior where scheduled console applications run hidden despite explicit configuration to the contrary. This becomes particularly problematic when:

  • Applications require real-time console output monitoring
  • Debugging scheduled batch processes
  • Interactive console applications need user input

The root cause lies in the security model changes introduced in Windows Server 2008. When creating a task:

# Incorrect configuration that forces hidden mode
$action = New-ScheduledTaskAction -Execute "C:\app\consoleapp.exe"
$settings = New-ScheduledTaskSettingsSet -Hidden $false
Register-ScheduledTask -TaskName "MyApp" -Action $action -Settings $settings -User "SYSTEM"

The above appears correct but will still run hidden because the SYSTEM account has no visible desktop session.

Method 1: Using Interactive Mode (Requires Logged-in User)

schtasks /create /tn "VisibleConsoleTask" /tr "C:\app\consoleapp.exe" /sc daily /st 09:00 /rl HIGHEST /it

Key parameters:

  • /it - Runs only when user is logged on (interactive)
  • /rl HIGHEST - Ensures proper privilege elevation

Method 2: VBScript Wrapper Approach

Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "cmd /c C:\app\consoleapp.exe", 1, False
Set WshShell = Nothing

Save as visible_wrapper.vbs and schedule this instead of your direct EXE.

For services that must run as SYSTEM but need visibility:

# PowerShell script to launch visible console
$psi = New-Object System.Diagnostics.ProcessStartInfo
$psi.FileName = "cmd.exe"
$psi.Arguments = "/c C:\app\consoleapp.exe"
$psi.WindowStyle = [System.Diagnostics.ProcessWindowStyle]::Normal
[System.Diagnostics.Process]::Start($psi)

For legacy systems where other methods fail:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Windows]
"NoInteractiveServices"=dword:00000000

Warning: This affects system security and should only be used in controlled environments.

To test if your application will actually run visible:

# PowerShell test command
Start-Process "C:\app\consoleapp.exe" -WindowStyle Normal -PassThru

If this shows your console window but the scheduler doesn't, revisit your task configuration.


Many developers migrating from Windows Server 2003 to 2008/R2 or newer versions encounter this frustrating behavior: scheduled console applications that worked perfectly visible in 2003 now run hidden by default. Despite the "Run whether user is logged on or not" option being unchecked and "Do not store password" being selected, the Task Scheduler stubbornly hides the console window.

The root cause lies in Windows security enhancements. When Task Scheduler launches a process without stored credentials (the more secure approach), Windows creates the process in session 0 - which has no visible desktop. This occurs regardless of the "Hidden" checkbox in task properties.

Here are several working approaches, ranked by effectiveness:

Method 1: Force Interactive Session

schtasks /change /tn "YourTaskName" /it

This command sets the "Run only when user is logged on" flag and adds interactive privileges. The /it switch is crucial for visibility.

Method 2: Registry Hack for Legacy Behavior

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa]
"DisableLoopbackCheck"=dword:00000001

Warning: This affects security settings. Only use in controlled environments.

Method 3: Visible Wrapper Script

Create a VBS script to launch your console app visibly:

Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "cmd /c C:\path\to\your\app.exe", 1, False
Set WshShell = Nothing

For .NET applications, you can create a small launcher that forces visibility:

using System;
using System.Diagnostics;

class VisibleLauncher {
    static void Main(string[] args) {
        ProcessStartInfo psi = new ProcessStartInfo {
            FileName = "YourApp.exe",
            UseShellExecute = true,
            WindowStyle = ProcessWindowStyle.Normal
        };
        Process.Start(psi);
    }
}

Always verify visibility with these steps:

  1. Run the task manually through Task Scheduler UI first
  2. Check Windows logs (Event Viewer → Applications)
  3. Add logging to your console app to confirm execution

Remember that forcing visibility may have security implications:

  • Interactive tasks require the user to be logged in
  • Visible windows can be captured by screen sharing tools
  • Stored credentials are less secure than system account execution