Resolving Locked WinCC Alarm Logging Databases During PCS 7 Project Archiving
An error stating that Alarm Logging (ALG) database files (.mdf/.ldf) are not closed when attempting to archive a SIMATIC PCS 7 project in SIMATIC Manager occurs because Microsoft SQL Server (WINCC instance) or residual WinCC background processes retain active operating system file locks on runtime segment databases. Stopping the SQL Server service alone is insufficient and can lead to database corruption. To resolve this: execute the official Siemens utility Reset_WinCC.vbs located under Siemens\WinCC\bin to cleanly terminate all background WinCC processes (CCProjectMgr, CCArchiveManager), detach attached ALG segments from the WINCC SQL instance, and release all file handles before executing File -> Archive.
Table of Contents
- Executive Summary
- Architecture and Fundamental Mechanics
- Step-by-Step Implementation Procedure
- Verification
- Limitations and Operational Precautions
- Engineer FAQ
- Technical References
- Related Articles
- Related Tags
Executive Summary
In SIMATIC PCS 7 multi-projects where an Operator Station (OS) runs locally on the Engineering Station (ES)—common in test environments, small skid plants, or during commissioning—engineers frequently encounter archive failures when selecting File -> Archive in SIMATIC Manager. The archiving utility halts with an error declaring that specific Alarm Logging (ALG) database files cannot be copied because they are open or locked. Even after closing WinCC Explorer and manually stopping the SQL Server (WINCC) service, the operating system continues to report file contention. This article diagnoses the background process architecture of WinCC Alarm Logging and provides the supported procedure to release database locks.
Architecture and Fundamental Mechanics
The file architecture and database locking mechanisms of WinCC Alarm Logging operate through structured SQL Server segmentation:
-
Alarm Logging Database Segmentation: WinCC Alarm Logging stores historical alarm and message events in cyclic SQL Server database segments. These files are saved in the project's archive folder (
<Project_Path>\<OS_Name>\ArchiveManager\AlarmLoging) with naming conventions such as<Project>_ALG_<Date_Time>.mdfand*.ldf. At any given time, the active runtime segment and several recent historical segments remain attached to the Microsoft SQL ServerWINCCinstance. -
Why Closing WinCC Explorer Leaves Locks Active: Exiting WinCC Explorer does not automatically detach or unload SQL Server database files. To optimize restart times, WinCC maintains background communication services (
CCProjectMgr.exe,CCArchiveManager.exe,CCExpCom.exe) that remain loaded in Windows memory. Furthermore, the Microsoft SQL Server service (sqlservr.exe -sWINCC) maintains exclusive operating system read/write locks on every attached.mdfand.ldffile. -
The Failure of Manual Service Stopping: When an engineer manually stops the
SQL Server (WINCC)service via Windows Services (services.msc), attached databases may be left in an 'In-Recovery' or 'Dirty-Shutdown' state. Moreover, child processes or theSQL Server Browserservice can hold open file handles. When SIMATIC Manager attempts to compress the directory into a.ziparchive, the Windows filesystem rejects access to locked database files. -
The Role of Reset_WinCC.vbs: Siemens provides the specialized script
Reset_WinCC.vbsto execute a graceful shutdown sequence: it commands WinCC database managers to flush transaction logs, cleanly detaches all temporary and cyclic archive segments from theWINCCSQL instance, and terminates lingering WinCC executables without damaging the database.
Step-by-Step Implementation Procedure
Execute the following procedure to release database locks and achieve a clean archive:
-
Close WinCC Explorer and Deactivate Runtime:
- If WinCC Runtime is active, deactivate it cleanly from the runtime screen or WinCC Explorer.
- Close WinCC Explorer completely. -
Execute Reset_WinCC.vbs:
- Open Windows File Explorer and navigate to the WinCC installation directory:
C:\Program Files (x86)\Siemens\WinCC\bin(orC:\Program Files\Siemens\WinCC\binon 32-bit systems).
- Right-clickReset_WinCC.vbsand selectOpen(or execute it from an elevated Windows Command Prompt:cscript Reset_WinCC.vbs).
- A command window will open, systematically detaching database segments and terminating background WinCC processes.
- Wait until the script displaysReset_WinCC: Finished. -
Inspect and Stop SQL Browser Service if Necessary:
- Open Windows Services (services.msc).
- TheSQL Server Browserservice resolves instance ports for external SQL clients; while usually benign, you can safely setSQL Server BrowsertoStopduring offline archiving if network clients are attempting to connect. -
Verify Process Elimination in Task Manager:
- Open Windows Task Manager (Ctrl+Shift+Esc).
- Verify that processesCCProjectMgr.exe,CCArchiveManager.exe,CCExpCom.exe, andPassDBProvider.exeare completely absent. -
Execute Archiving in SIMATIC Manager:
- Open SIMATIC Manager.
- SelectFile -> Archive.
- Select the target multiproject or project, choose the destination drive, and selectNo compressionorZIP archive.
- Archiving will now proceed smoothly without ALG database lock errors.
Verification
Confirm complete archiving success and project restorability:
-
Archive Generation Audit: Confirm that SIMATIC Manager completes the archive process with status 'The archive was created successfully' and zero file-skip warnings.
-
Archive Content Inspection: Open the resulting
.ziparchive using 7-Zip or Windows Explorer. Inspect the directory structure underwincproj\<OS_Name>\ArchiveManager\AlarmLoging. Confirm that.mdfand.ldffiles are present and uncorrupted. -
Clean Retrieval Test: Test-retrieve the archive (
File -> Retrieve) into a temporary folder to ensure database headers attach cleanly when opened in WinCC Explorer.
Limitations and Operational Precautions
Never delete .mdf or .ldf files manually from the ArchiveManager directory in an attempt to force an archive to succeed; doing so destroys historical alarm records and causes SQL Server database corruption upon next project launch. If specific old archive segments are no longer needed, use WinCC Archive Manager settings to configure maximum size or time limits cleanly.
Engineer FAQ
Why are Alarm Logging (ALG) databases locked when WinCC Explorer is closed?
WinCC background services and Microsoft SQL Server remain active in memory to maintain fast project switching, keeping exclusive operating system file handles on attached database files.
What does Reset_WinCC.vbs do?
It cleanly detaches all project and archive databases from SQL Server, flushes transaction logs, and terminates lingering WinCC background processes.
Can I stop the SQL Server Browser service?
Yes. The SQL Server Browser service only assists external clients in locating SQL instances and can be safely stopped during project archiving.
Does executing Reset_WinCC.vbs delete historical alarms?
No. It simply detaches database files from the SQL Server process; all historical alarm and tag logging data files remain intact on disk.
Why shouldn't I kill sqlservr.exe in Task Manager?
Forcefully terminating sqlservr.exe while transactions are being written can corrupt database headers, requiring database repairs or project restoration.
Technical References
- WinCC V7.5 Information System: Working with Projects and Archiving
- Siemens Industry Online Support: Using Reset_WinCC.vbs to Terminate WinCC Processes
- SIMATIC PCS 7 Engineering System Configuration Guide
Related Articles
- Resolving SQL Server Data Access Errors During WinCC OS Download
- Hardware Homogeneity and Synchronization Rules for Redundant WinCC OS Servers
- Updating Faceplates and OS Project Editor Basic Data Following PCS 7 Migration
Related Tags
- WinCC Archiving
- Alarm Logging
- SQL Server
- Reset_WinCC
- Database Lock
- SIMATIC Manager