Problem Overview
WinCC 7.2 AutostartRT fails to bring a runtime project online after a host reboot on Windows Server 2008 R2. After 15-20 minutes of stalled loading, the runtime dialog reports:
Error while opening the project \\SRV-SCADA-EN\<project> ... Autostart not possible.
The same project opens successfully when launched manually (via WinCC Explorer or a desktop shortcut), reaching the runtime surface in roughly two minutes. The automated path never recovers without a manual restart of the runtime.
Concurrent Windows Application and SQL Server logs show an authentication failure against the WinCC project database at the moment AutostartRT tries to attach it:
01/20/2015 13:31:13, Logon, Unknown, Login failed for user 'SRV-SCADA-EN\Administrator'.
Reason: Failed to open the explicitly specified database. [CLIENT: <local machine>]
01/20/2015 13:31:13, Logon, Unknown, Error: 18456, Severity: 14, State: 38.
This combination is a classic SQL Server "login OK, database not yet reachable" failure during service-startup sequencing.
Environment Snapshot
| Component | Version / Configuration |
|---|---|
| SCADA software | SIMATIC WinCC V7.2 (Update x, ASIA / Europe variant) |
| Operating system | Windows Server 2008 R2 SP1, 64-bit |
| Database engine | Microsoft SQL Server 2008 R2 (WinCC bundled instance, default instance or WINCCINSTANCE) |
| Connectivity stack | No SIMATIC Net installed (standalone WinCC server) |
| Runtime account | SRV-SCADA-EN\Administrator (domain or local Administrator) |
| Autostart mechanism | WinCC Explorer -> Computer -> AutostartRT configured + WinCC_Batch + wait.exe |
| Behavior | Manual start 2 min, Autostart 15-20 min then abort |
Root Cause Analysis
SQL Server error 18456 is the generic "Login Failed" class. The state code is the only reliable indicator of the underlying problem.
| Error 18456 State | Meaning | Typical Trigger |
|---|---|---|
| 1 - 2 | Credential error (state hidden for security) | Wrong password, login disabled |
| 5 | Login does not exist | Orphaned login, mistyped name |
| 7 | Login disabled | DBA revoked CONNECT |
| 8 | Password mismatch | Password policy drift |
| 38 | Login OK, target database unavailable / not yet online / permission denied at DB level | Database not recovered, default DB offline, login not mapped to DB user, contained DB mismatch |
State 38 with the message "Failed to open the explicitly specified database" indicates that the SQL login authenticates successfully but the database WinCC asked it to use is not yet in a state that allows a connection. During server boot the WinCC runtime service attempts to open the WinCC project database before the SQL Server service has completed recovery of that database, or before the WinCC-specific login has been mapped to a database user with the db_owner / public rights it requires.
The reason Autostart hangs for 15-20 minutes (the SQL Server default connection timeout plus retry behavior in the WinCC startup path) while manual launch completes in 2 minutes is sequencing: the human starts WinCC Explorer long after SQL Server is fully recovered, so the same login succeeds immediately. Autostart fires within seconds of the OS login session, while SQL Server is still finalizing recovery on slow disks or under antivirus interference.
Pre-Diagnostic Checklist
- Open SQL Server Management Studio on the WinCC server and confirm the SQL Server service state is "Running (Recovery)" vs. "Running (Online)". The recovery state during boot is the trigger.
- Run the query below and note the
state_descanduser_access_descof each WinCC database:SELECT name, state_desc, user_access_desc, is_read_only, is_in_standby FROM sys.databases WHERE name LIKE 'CC%' OR name LIKE 'WinCC%' OR name = 'master'; - Confirm the SQL login used by the WinCC runtime exists and is enabled:
SELECT name, type_desc, is_disabled, default_database_name FROM sys.server_principals WHERE name = 'SRV-SCADA-EN\Administrator'; - Verify the database user mapping for every WinCC database:
SELECT dp.name AS db_user, dp.type_desc, dp.authentication_type_desc, r.name AS role_name FROM sys.database_principals dp LEFT JOIN sys.database_role_members rm ON dp.principal_id = rm.member_principal_id LEFT JOIN sys.database_principals r ON rm.role_principal_id = r.principal_id WHERE dp.name = 'SRV-SCADA-EN\Administrator' OR dp.sid = SUSER_SID('SRV-SCADA-EN\Administrator'); - Check Windows Event Viewer -> Application for SQLSERVER and WinCC event IDs 18456, 17204, 17207, 9001, 9002 (recovery and I/O related).
- Inspect the WinCC project directory
<ProjectPath>\<ComputerName>\<ProjectName>.mdffile lock state usingProcess Explorerorhandle.exe. - Confirm no antivirus, backup agent, or disk-snapshot tool is locking the MDF/LDF files during the early boot window.
Resolution Path A - Repair SQL Login and Database Mapping
The fastest, deterministic fix is to make sure the account AutostartRT uses has a valid, online mapping to every WinCC database at the moment WinCC requests it.
- Open SQL Server Management Studio as a member of
sysadmin. - For the WinCC service login, re-create the database user in every WinCC database and assign
db_owner:USE [CC_Project_xxx]; CREATE USER [SRV-SCADA-EN\Administrator] FOR LOGIN [SRV-SCADA-EN\Administrator]; ALTER ROLE db_owner ADD MEMBER [SRV-SCADA-EN\Administrator]; -- Repeat for CC_Alarms, CC_Logging, CC_UserArchives, CC_RTDatabase, etc. - Set the default database explicitly to the WinCC project database to avoid "default database unavailable" state 38:
ALTER LOGIN [SRV-SCADA-EN\Administrator] WITH DEFAULT_DATABASE = [CC_Project_xxx]; - Confirm the WinCC SQL login (machine-scoped)
CCAdmin$<PC>and the dedicated runtime users exist and own the runtime database. Refer to the WinCC V7.2 Installation Notes / Configuration Manual for the exact list of logins the installer creates. - Restart the SQL Server (MSSQLSERVER) service and verify
state_desc = ONLINEfor all WinCC databases before reattempting Autostart.
Resolution Path B - Service Dependency and Boot Sequencing
If the database mapping is correct but SQL Server simply is not online when Autostart fires, force the WinCC runtime to start strictly after SQL Server has finished recovery.
- Open
services.msc. - Locate SIMATIC WinCC Explorer / CCAgentStartup / WinCC Runtime depending on the deployed configuration.
- Open Properties -> Dependencies tab and add:
SQL Server (MSSQLSERVER)-
SQL Server Agent (MSSQLSERVER)if used -
Server(the Workstation/Server service - WinCC uses it for UNC and license paths)
- Set the service Startup type to
Automatic (Delayed Start)with a 60-120 s delay. The "Manual start works because the operator waits" observation is exactly what a delayed start reproduces legitimately. - If the WinCC runtime is launched via AutostartRT from
WinCCExplorer.exe /Activate, replace it with a script dependency on the SQL Server service (see Resolution Path C).
Resolution Path C - Configure AutostartRT With SQL Wait Logic
Siemens documents two canonical methods for AutostartRT on WinCC V7.x: the WinCC_Batch.bat plus wait.exe helper, and the explicit configuration of AutostartRT in WinCC Explorer for server / client / redundant scenarios.
- In WinCC Explorer open Computer properties -> Autostart tab. Enable AutostartRT and define the startup list explicitly rather than relying on the project default.
- Create a launcher batch file that polls SQL Server before starting the runtime:
@echo off
REM === WinCC_AutostartRT_Dependency.bat ===
set SQL_INSTANCE=.\WINCC
set TARGET_DB=CC_Project_xxx
:WAIT_SQL
sqlcmd -S %SQL_INSTANCE% -Q "SELECT 1" -h -1 -W >nul 2>&1
if errorlevel 1 (
echo [%date% %time%] SQL Server not ready, retrying...
timeout /t 10 /nobreak >nul
goto WAIT_SQL
)
:WAIT_DB
for /f "usebackq tokens=*" %%a in (`sqlcmd -S %SQL_INSTANCE% -h -1 -Q "SET NOCOUNT ON; SELECT COUNT(*) FROM sys.databases WHERE name='%TARGET_DB%' AND state_desc='ONLINE'"`) do set DB_OK=%%a
if "%DB_OK%" NEQ "1" (
echo [%date% %time%] Database %TARGET_DB% not ONLINE yet, retrying...
timeout /t 10 /nobreak >nul
goto WAIT_DB
)
echo [%date% %time%] SQL and DB ready. Launching WinCC Runtime...
"C:\Program Files (x86)\Siemens\WinCC\bin\WinCCExplorer.exe" "C:\Program Files (x86)\Siemens\WinCC\WinCCProjects\<Project>\<Computer>.pck" /Activate
- Disable the built-in AutostartRT checkbox in WinCC Explorer to prevent the original 15-20 min failure path from running in parallel.
- Drop the script into
%ProgramData%\Microsoft\Windows\Start Menu\Programs\Startup\or schedule it as a Windows Task with the trigger "At system startup" and the condition "Start only if the computer is on AC power". - Keep
wait.exefrom the Siemens FAQ referenced in Manual Workaround below if a simpler fixed-delay approach is acceptable.
Manual Workaround - WinCC_Batch With wait.exe
This is the documented "good enough" approach when timing fixes are not allowed. The wait.exe utility is delivered with WinCC V7.x and lets the batch hold the runtime launch for a fixed duration after SQL Server starts.
- Copy
wait.exefrom the WinCC installation media toC:\Program Files (x86)\Siemens\WinCC\bin\. - Create
WinCC_Batch.bat:
@echo off
REM Wait 180 seconds so SQL Server has finished recovery
"C:\Program Files (x86)\Siemens\WinCC\bin\wait.exe" 180
"C:\Program Files (x86)\Siemens\WinCC\bin\WinCCExplorer.exe" /Activate
- Disable AutostartRT in WinCC Explorer to prevent the failing path.
- Place the batch in the user Startup folder for the account that logs on at boot, or convert it to a Windows Task scheduled to run as
SYSTEMwith delay.
Related WinCC V7.2 Configuration Items
| Setting | Location | Recommended Value |
|---|---|---|
| AutostartRT activation | WinCC Explorer -> Computer -> Properties -> Autostart | Either enabled with full project list, or disabled and replaced by launcher script |
| Runtime database path | Computer properties -> Graphics Runtime -> Runtime Database | Local path, not UNC, to avoid Server service race |
| SQL Server startup account | SQL Server Configuration Manager -> SQL Server Services | Domain account with read/write to MDF/LDF on local disk |
| WinCC Service Mode | Computer properties -> Startup | Service mode configured if headless boot is required |
| Antivirus exclusions | Windows Security -> Virus & threat protection -> Exclusions | Exclude C:\Program Files (x86)\Siemens\WinCC\ and *.mdf / *.ldf
|
Verification
- Reboot the server and let it boot unattended - do not log in early.
- Wait for the WinCC runtime surface to appear or confirm via the
CCAgentCtrl.exe/WinCCExplorer.exeprocess that the runtime process is running with the correct project context. - Inspect SQL Server logs for the same boot window. The line
Login failed ... State 38must be absent. - Open WinCC Alarm Logging and Tag Logging runtime databases in SQL Management Studio and confirm they accept queries immediately after boot.
- Force a SQL Server service restart and confirm the launcher script retries automatically until the database is online, then brings WinCC up.
- Validate licensing: the WinCC license plug-in must be present before SQL Server recovery reaches a state where the runtime will query it; otherwise a related but different failure appears.
Troubleshooting Matrix
| Symptom | Likely Cause | Diagnostic Command / Log | Fix |
|---|---|---|---|
| 18456 State 38 at boot, manual start OK | SQL Server still in recovery when WinCC service starts | SQL log + WinCC startup log | Service dependency or launcher script with DB-online wait |
| 18456 State 5 / 7 | Login does not exist or is disabled | SELECT name, is_disabled FROM sys.server_principals | Re-create login, set default DB, enable |
| 18456 State 8 | Password expired or policy mismatch | SQL logon audit + Windows event 4740 | Reset password, set CHECK_POLICY = OFF if service account is not interactive |
| 17204 / 17207 in SQL log | MDF / LDF inaccessible | SQL errorlog | Check file permissions, unlock from AV, repair disk |
| Runtime starts then crashes immediately | License not loaded yet | WinCC license log, Automation License Manager | Delay WinCC start until License Server is responding |
| Autostart 20 min timeout then "Autostart not possible" | Default WinCC Autostart timeout expired | WinCC startup log | Increase AutostartRT timeout in registry or use launcher script |
| Works after hot reboot but not cold boot | Disk / SAN not ready | Windows disk event IDs, SAN logs | Set SQL Server service to "Automatic (Delayed Start)" |
Preventive Hardening
- Move WinCC runtime databases to a dedicated local volume and exclude the volume from any real-time AV scan.
- Make SQL Server Automatic (Delayed Start) so it never races with disk initialization.
- Use a dedicated service account for SQL Server instead of LocalSystem when the WinCC project path is on a UNC share.
- Keep WinCC V7.2 at the latest update level (V7.2 SP1 / V7.2 ASIA Update releases) - Siemens patched several AutostartRT startup race conditions over the lifetime of V7.2.
- Document the dependency chain: SQL Server -> CCAgent -> WinCC Runtime. Without this, every Windows update reintroduces the race.
- Centralize the SQL audit log review so future 18456 events trip a monitoring rule immediately rather than being discovered weeks later.
FAQ
What does SQL Server Error 18456 State 38 mean for WinCC AutostartRT?
It means the SQL login authenticated successfully, but the target database was not online or accessible at the moment WinCC tried to open it. In a WinCC Autostart scenario this is almost always a startup sequencing problem: SQL Server is still in recovery when AutostartRT fires, so the database cannot yet be opened. Add SQL Server as a service dependency for the WinCC runtime, or replace AutostartRT with a launcher script that waits until the WinCC databases report state_desc = ONLINE.
Why does manual start of WinCC succeed but AutostartRT fails on the same server?
Manual start is triggered by an operator after the OS, all services, and SQL Server have fully started. AutostartRT runs within the boot sequence, often while SQL Server is still recovering large WinCC databases. The same login that fails during boot therefore succeeds a few minutes later. The fix is sequencing, not permissions.
Do I need SIMATIC Net installed to use WinCC AutostartRT?
No. SIMATIC Net is required only when WinCC communicates with S7 PLCs over industrial protocols (ISO, TCP, PROFIBUS, PROFINET). For a standalone WinCC server with OPC UA, Modbus, or third-party connectivity, AutostartRT works without SIMATIC Net. The relevant FAQs cover both configurations.
Can a fixed wait.exe delay be the production solution for WinCC AutostartRT?
It can be acceptable for small to mid-size projects where boot time variation is bounded. For larger projects with multi-GB runtime databases, or any environment with antivirus or backup agents active at boot, replace the fixed delay with an explicit database-online check using sqlcmd or a similar query inside the launcher script. This eliminates the 15-20 minute failure window regardless of how long SQL recovery actually takes.
Which Windows account should own the SQL logins for a WinCC V7.2 server?
Use the dedicated WinCC runtime account (typically CCAdmin$<ComputerName> for the system account and a named domain account for the interactive user) rather than a generic Administrator. Map that account in every WinCC database (CC_Project, CC_Alarms, CC_Logging, CC_UserArchives, CC_RTDatabase) with the db_owner role, set DEFAULT_DATABASE to the project database, and confirm the login is not disabled in sys.server_principals.