是否可以从bat文件中清除msmq队列?
从本质上讲,我想创建一个bat文件,或者至少是一些快速简单的文件,这样未经培训的员工就可以在不知道任何shell或管理工具的情况下单击并修复
有没有人能帮我指个方向?
发布于 2012-08-03 18:06:27
看一看MSMQAdm Utility
通过实用程序管理的任务包括:
浏览本地queues
的连接
别忘了powershell,看看PowerShell Community Extensions吧
更新
打开powershell并逐行写入
[Reflection.Assembly]::LoadWithPartialName("System.Messaging")
$queueName = '.\Private$\testQueue'
$queue = new-object -TypeName System.Messaging.MessageQueue -ArgumentList $queueName
$queue.Purge()从cmd调用powershell
上插入
从cmd调用脚本的最简单方法。
powershell.exe -executionpolicy Unrestricted C:\purgemsmq.ps1
发布于 2014-03-18 03:32:33
THis代码可以工作:
[Reflection.Assembly]::LoadWithPartialName("System.Messaging") | Out-Null
$Name=(get-wmiobject win32_computersystem).name
$QName=(
"FormatName:Direct=OS:$name\System$;DEADXACT",
"FormatName:Direct=OS:$name\System$;DEADLETTER"
)
foreach ($Q in $Qname){
$MessageQueue = New-Object System.Messaging.MessageQueue($Q)
$MSGCount=$($MessageQueue.GetMessageEnumerator2()).count
IF($MSGCount){
$MessageQueue.Purge()
Write-Host "$Q has been purged of $MSGCount messages." -ForegroundColor green
}
Else{
Write-Host "$Q is clean"}
} 发布于 2014-10-14 20:42:14
清除本地计算机上所有专用队列的PowerShell脚本:
[Reflection.Assembly]::LoadWithPartialName("System.Messaging")
$MachineName=(get-wmiobject win32_computersystem).name
[System.Messaging.MessageQueue]::GetPrivateQueuesByMachine("$MachineName") | % { $_.Purge(); }正如https://stackoverflow.com/a/11793579/1235394中所解释的,执行它的最简单方法是:
purge-private-msmq-queues.ps1purge-private-msmq-queues.cmd:.\purge-private-msmq-queues.ps1 -executionpolicy不受限制的powershell
https://stackoverflow.com/questions/11793441
复制相似问题