Purge MSMQ queue and reset IIS from a bat file

前端 未结 3 1269

Is it possible to purge a msmq queue from a bat file?

Essentially I want to make a bat file or at least something quick and easy so that an untrained employee can cl

3条回答
  •  星月不相逢
    2021-01-02 11:38

    PowerShell script to purge all private queues on local machine:

    [Reflection.Assembly]::LoadWithPartialName("System.Messaging")
    $MachineName=(get-wmiobject win32_computersystem).name
    [System.Messaging.MessageQueue]::GetPrivateQueuesByMachine("$MachineName") | % { $_.Purge(); }
    

    As explained in https://stackoverflow.com/a/11793579/1235394, easiest way to execute it is:

    • save script to file purge-private-msmq-queues.ps1
    • in the same folder create script file purge-private-msmq-queues.cmd with following content:

      powershell -executionpolicy Unrestricted .\purge-private-msmq-queues.ps1
      

提交回复
热议问题