Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 清除MSMQ队列并从bat文件重置IIS_Batch File_Msmq - Fatal编程技术网

Batch file 清除MSMQ队列并从bat文件重置IIS

Batch file 清除MSMQ队列并从bat文件重置IIS,batch-file,msmq,Batch File,Msmq,是否可以从bat文件中清除msmq队列 基本上,我想制作一个bat文件或至少是一些快速简单的东西,这样未经培训的员工就可以在不知道任何shell或管理工具的情况下单击并修复 有人能帮我找到正确的方向吗?看一看 通过实用程序管理的任务包括: 浏览本地队列 清除消息 删除单个邮件 停止和启动MSMQ服务 连接和断开与网络的连接 别忘了powershell,看看吧 更新 打开powershell并逐行写入 [Reflection.Assembly]::LoadWithPartialName("Sy

是否可以从bat文件中清除msmq队列

基本上,我想制作一个bat文件或至少是一些快速简单的东西,这样未经培训的员工就可以在不知道任何shell或管理工具的情况下单击并修复

有人能帮我找到正确的方向吗?

看一看

通过实用程序管理的任务包括:

  • 浏览本地队列
  • 清除消息
  • 删除单个邮件
  • 停止和启动MSMQ服务
  • 连接和断开与网络的连接
别忘了powershell,看看吧

更新

打开powershell并逐行写入

[Reflection.Assembly]::LoadWithPartialName("System.Messaging")
$queueName = '.\Private$\testQueue'
$queue = new-object -TypeName System.Messaging.MessageQueue -ArgumentList $queueName
$queue.Purge()
从cmd调用powershell

  • 创建txt文件
  • 插入所有行
  • 更改“ps1”上的文件扩展名
  • 从cmd调用脚本的最简单方法

    powershell.exe-执行策略无限制C:\purgemmq.ps1

    此代码适用于:

    [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"}
    
    } 
    

    清除本地计算机上所有专用队列的PowerShell脚本:

    [Reflection.Assembly]::LoadWithPartialName("System.Messaging")
    $MachineName=(get-wmiobject win32_computersystem).name
    [System.Messaging.MessageQueue]::GetPrivateQueuesByMachine("$MachineName") | % { $_.Purge(); }
    
    如中所述,最简单的执行方法是:

    • 将脚本保存到文件
      清除专用msmq队列。ps1
    • 在同一文件夹中,创建脚本文件
      purge private msmq queues.cmd
      ,其中包含以下内容:

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

    好的,我来看看。但本质上我想制作一个bat文件,或者至少是一个简单快捷的文件,这样未经培训的员工就可以在不知道任何shell或管理工具的情况下单击并修复。Msmq没有命令行实用程序。请参阅添加的powershell命令,只需打开powershell并逐行插入所有命令谢谢!这能以任何方式实现自动化吗?让我们这样做吧。1) 创建txt文件。2) 插入所有行3)更改“ps1”上的文件扩展名。4) 从cmd调用脚本的最简单方法。powershell.exe-executionpolicy Unrestricted C:\purgemmq.ps1Along,带有代码,请尝试解释一下。