VBScript Code Example: Creating a Queue


Updated: July 19, 2016

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

The following example creates a nontransactional public queue. The queue is created on a Web server using Active Server Pages and VBSript.

System_CAPS_ICON_note.jpg Note

By default, ASP pages run under the local IUSR_comptername account created by Internet Information Services (IIS). Therefore, by default, local users can create only local public queues and cannot create queues on a remote computer using ASP pages. However, administrators can change the default ASP permissions. In IIS, they can allow anonymous access through domain user accounts that can create queues, and in Message Queuing, they can allow everyone to create queues.

The following procedure lists the steps used to create the queue in the code example that follows.

To create a queue

  1. Create an MSMQQueueInfo object.

  2. Specify the path name of the queue. (In the following example, "." is used to indicate the local computer.)

System_CAPS_ICON_note.jpg Note

For Message Queuing servers and independent clients, the local machine is the local computer. However, for dependent clients, the local machine is the client's supporting server.

  1. Optional. Add any additional queue properties you need. (The following example also specifies the label of the queue using MSMQQueueInfo.Label

  2. Call MSMQQueueInfo.Create to create the queue.

To run this example, paste the following code into a text file that has an .asp file extension (for example, mq.asp), and then place the file in the InetPub\Scripts folder on your Web server. (If you use another folder, make sure that folder has execute script privileges.) You can then run this script from your Internet browser by referring to the address: http ://<webservername>/scripts.mq.asp.

The following code contains no version specific Message Queuing calls.

<H1>Creating an MSMQ public queue on a Web server</H1>  
    set qinfo = Server.CreateObject ("MSMQ.MSMQQueueInfo")  
    qinfo.PathName = ".\TestQueue"  
    qinfo.Label = "Test Queue"