Applies To: Windows 10, Windows 7, Windows 8, Windows 8.1, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012, Windows Server 2012 R2, Windows Server Technical Preview, Windows Vista

(Introduced in MSMQ 3.0.) The Tidy method of the MSMQApplication object cleans up empty message files.

Sub Tidy


This method has no parameters.

Return Values

This method has no return values.

Error Codes

This method generates one of the following error codes:

MQ_OK (0)

The method call was successful.


The access rights for performing management actions on the computer are not allowed for the calling process.


The application is unable to connect to the queue manager.

For a complete list of error and information codes, see Message Queuing Error and Information Codes.


Including the MSMQApplication object in the code syntax is optional because this object is defined as the application object, whose methods and properties are globally available.

This method cleans up empty message files, regardless of the automatic cleanup interval used by Message Queuing. Message Queuing automatically cleans up empty message files based on its default six hour cleanup interval or based on the MessageCleanupInterval registry value.

This method (by default) applies to the local computer. To reference another computer, set MSMQApplication.Machine to another computer and call this method again.

Local administrative permissions are needed to clean up the empty message files on a computer.

In C++ COM applications, you must use a smart pointer to the IMSMQApplication3 interface to expose the Tidy method.

Equivalent API Function

When using API functions, call MQMgmtAction and pass "TIDY" as the string indicating the action to be performed on the computer to clean up empty message files.


Windows NT/2000/XP: Included in Windows XP and Windows Server 2003.

Windows 95/98/Me: Unsupported.

Header: Declared in Mqoai.h.

Library: Use Mqoa.lib.

See Also