VB.NET (WCF) --> CMD 文件 -->第 3 方应用程序

发布于 2024-11-09 18:24:58 字数 725 浏览 6 评论 0原文

我有一个驻留在服务器上的自托管 WCF 服务 (VB)。该服务有一个方法,我从另一个应用程序调用该方法,该方法应该启动一个调用第三方程序的 .cmd 文件。

我的 WCF 使用了旧的 Shell() 命令和 Process() 对象。两者都可以调用 .cmd 文件(位于服务器的本地驱动器上)。 .cmd 文件如下所示:

echo Before calling 3rd party app >> C:\HelloFubar.txt
cd C:\Program Files\Exstream\Dialog 6.1
Engine -CONTROLFILE=C:\Exstream\Development\LetterWriter\Control Files\Letter.opt
echo After calling 3rd party app >> C:\HelloFubar.txt

现在我知道 .cmd 文件(另存为 Letter.cmd)正在触发,因为当我在测试应用程序后检查 txt 文件时,之前/之后的语句已被写入。但是,第 3 方应用程序无法启动。

现在奇怪的部分 - 如果我双击资源管理器中的 cmd 文件,测试语句将被写入文本文件,并且第 3 方应用程序将启动。运行得很好。

我已经仔细检查了应用程序和相应的文件,以确保 NETWORK_SERVICE 具有权限并且我的服务正在该帐户下运行。所以这似乎不是一个配股问题。

有什么想法吗?

谢谢, 贾森

I have a self-hosted WCF service (VB) residing on a server. This service has a method, which I call from another application, that is supposed to kick off a .cmd file which calls a 3rd party program.

My WCF has used both the old Shell() command and the Process() object. Both can call the .cmd file (located on the server's local drive). The .cmd file looks like this:

echo Before calling 3rd party app >> C:\HelloFubar.txt
cd C:\Program Files\Exstream\Dialog 6.1
Engine -CONTROLFILE=C:\Exstream\Development\LetterWriter\Control Files\Letter.opt
echo After calling 3rd party app >> C:\HelloFubar.txt

Now I know the .cmd file (saved as Letter.cmd) is firing because when I check the txt file after testing my app, the before/after statements have been written. However, the 3rd party application does not start.

Now the weird part -- if I double click the cmd file from explorer, the test statements are written to the text file AND the 3rd party application kicks off. Runs great.

I've double-checked the application and corresponding files to make sure NETWORK_SERVICE has permissions and my service is running under that account. So this does not seem to be a rights issue.

Any ideas?

Thanks,
Jason

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

软甜啾 2024-11-16 18:24:58

哇!只花了一两周的时间!

自我注意:

您必须确保从 NETWORK_SERVICE 帐户启动的任何第 3 方应用程序不会尝试执行 NETWORK_SERVICE 帐户没有明确权限执行的操作。比如写入注册表、删除文件等任务。

尝试在管理员帐户下启动服务,并确保在调用在 NETWORK_SERVICE 之外的任何帐户下运行的 WCF 时,在客户端中使用 servicePrincipalName 属性。客户端的配置文件中的一个示例如下:

<endpoint address="net.tcp://myserver-2:8080/Service" binding="netTcpBinding"
bindingConfiguration="NetTcpBinding_IService1" contract="TCPService.IService1"
name="NetTcpBinding_IService1">
  <identity>
     <servicePrincipalName value="MyServiceReferenceName(InSolutionExplorer)\myserver-2"/>
     <dns value="myserver-2.mydomain.local" />
  </identity>
</endpoint>

希望这可以帮助其他人!

Whew! Only took a week or two!

Note to self:

Self, you must make sure that any 3rd party applications kicked off from the NETWORK_SERVICE account are not trying to do things the NETWORK_SERVICE account does not have explicit rights to do. Like write to the registry, delete files and other tasks.

Try starting the service under an admins account, and make sure to use the servicePrincipalName attribute in the client when calling a WCF running under any account other than NETWORK_SERVICE. An example would be like this in the client's config file:

<endpoint address="net.tcp://myserver-2:8080/Service" binding="netTcpBinding"
bindingConfiguration="NetTcpBinding_IService1" contract="TCPService.IService1"
name="NetTcpBinding_IService1">
  <identity>
     <servicePrincipalName value="MyServiceReferenceName(InSolutionExplorer)\myserver-2"/>
     <dns value="myserver-2.mydomain.local" />
  </identity>
</endpoint>

Hope this can help somebody else out there!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文