How to Reopen CMD Prompt on Windows Server 2012 Core After Accidental Exit


1 views

Working with Windows Server 2012 Core edition presents unique challenges when you accidentally close your only command prompt window. Unlike the full GUI version where you can simply click the Start button to launch another, Core edition requires different approaches.

The most straightforward method is using remote management tools:

# Using PowerShell Remoting from another machine
Enter-PSSession -ComputerName ServerName -Credential (Get-Credential)

# Alternative using WinRM (must be pre-configured)
winrm quickconfig -quiet
winrs -r:ServerName cmd

If remote access isn't available, try these local solutions:

Task Manager Approach

1. Press Ctrl+Shift+Esc to open Task Manager
2. Click "File" > "Run new task"
3. Type "cmd.exe" and press Enter

Emergency Shortcut

Create a persistent CMD shortcut before closing your session:

# Create scheduled task that runs at logon
schtasks /create /tn "EmergencyCMD" /tr "cmd.exe" /sc onlogon /ru SYSTEM

# Then run immediately (if still in session)
schtasks /run /tn "EmergencyCMD"

For future sessions, implement these safeguards:

# Always run CMD with /K parameter
cmd /k "echo Warning: Use 'start cmd' before exiting!"

# Configure AutoAdminLogon (registry edit required)
reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AutoAdminLogon /t REG_SZ /d 1 /f
reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultUserName /t REG_SZ /d Administrator /f
reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultPassword /t REG_SZ /d YourPassword /f

When all else fails, consider these last-resort options:

  • Physical console access using KVM
  • Emergency Management Services (EMS) via serial port
  • Hyper-V console connection if running as VM

When you've closed the only CMD window on a Server Core installation, you can regain access using one of these methods:

# Method 1: Using Task Manager (GUI-less approach)
1. Press Ctrl+Shift+Esc to launch Task Manager
2. Go to File → Run new task
3. Type "cmd.exe" and press Enter

# Method 2: Via PowerShell remoting (if configured)
Enter-PSSession -ComputerName YourServer -Credential (Get-Credential)
Start-Process cmd.exe

For environments where the above doesn't work, consider these approaches:

  • Emergency Management Services (EMS): Requires pre-configuration but provides serial console access
  • Windows Remote Shell (WinRS): Execute winrs -r:servername cmd from another machine
  • SSH: If the Windows SSH server is installed

Add these registry tweaks to maintain access:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon]
"Shell"="cmd.exe /k start /b cmd.exe"

This ensures a new CMD instance launches automatically when the current one closes.

Create a scheduled task that maintains persistent access:

schtasks /create /tn "KeepAliveCMD" /tr "cmd.exe" /sc minute /mo 1 /ru "SYSTEM"
schtasks /run /tn "KeepAliveCMD"

For production environments, implement these best practices:

  1. Always maintain at least two active remote sessions
  2. Configure out-of-band management (iDRAC/iLO)
  3. Document emergency access procedures
  4. Implement Just-in-Time (JIT) access controls