使用 VBScript 设置 MSMQ 权限(通过 Nant)
我们正在使用 Nant 部署应用程序,并且需要在此过程中创建一些 MSMQ 队列。
我们使用 Nant/psexec/cscript 调用 VBScript 来创建队列本身,但我们还需要设置权限。
这可以通过编程来完成吗?
我知道在脚本中设置 MSMQ 队列的权限然而,该问题要求使用 PowerShell 或 VBScript,并且 PowerShell 有一个可接受的答案。我们没有可用的 PowerShell,因此这个问题特定于 VBScript。
We are using Nant to deploy an application and need to create some MSMQ Queues during the process.
We use Nant/psexec/cscript to call a VBScript to create the queue itself but we also need to set the permissions.
Can this be done programmatically?
I am aware of Setting permissions on a MSMQ queue in script however that question asks for PowerShell or VBScript and has an accepted answer for PowerShell. We do not have PowerShell available to us so this question is specific to VBScript.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据 这篇文章,MSMQ 脚本 API 不提供任何设置查询权限的方法,因此无法使用 VBScript 完成此任务。
我可以建议以下解决方法:
System.Messaging
程序集提供的 MSMQ .NET API。)MQSetQueueSecurity
(C 或 C++ 语言)MessageQueue.SetPermissions
(在 .NET 中)According to this post, MSMQ scripting API doesn't provide any means to set permissions on queries, so this task cannot be accomplished using VBScript.
I can suggest the following workarounds:
System.Messaging
assembly.)MQSetQueueSecurity
(in C or C++)MessageQueue.SetPermissions
(in .NET)刚刚遇到这个问题,发现没有答案。这里的技巧是直接在 nAnt 中使用 VB.Net 或 C# 代码。您可以使用 nAnt include 来完成此操作,并在全局空间中使用脚本任务;并在代码中派生自 Task 类。
或者。您可以将脚本块放入目标中。我更喜欢前一种方法,因为它更容易重用和传递参数。
无论哪种情况,这都不是 VBScript,它是完全编译的 .Net 代码,因此您几乎可以做任何事情。
在代码元素中,导入 System.Messaging,并在 ExecuteTask 覆盖中创建队列。不要忘记授予 .\Users 读/写/查看权限,否则您可能无法正确使用队列,除非运行 nAnt 脚本的用户(通常不是 Web 服务器或 Windows)正在读取队列的服务。)
此外,由于您具有对 Messaging.MessageQueue 类的完全访问权限,因此您可以检查现有队列是否存在并删除!
Just came across this and saw that it was unanswered. The trick here is to use VB.Net or C# code directly in nAnt. You can do this with a nAnt include, with a script task in the global space; and in the code, derive from the Task class.
Or. you can put your script block in a target. I prefer the former method, since it is easier to reuse and pass in parameters.
In either case, this is NOT VBScript, it is fully compiled .Net code, so you can do pretty much anything.
In your code element, Import System.Messaging, and create the Queue in your ExecuteTask override. Don't forget to give read/write/peek permissions to .\Users, or you probably don't be able to use the Queue properly except from the user that ran the nAnt script (which usually isn't the web server or Windows service that is reading the queue.)
Also, since you have full access to the Messaging.MessageQueue class, you can check for existence and delete an existing queue, or not!