How to use environment variable with IIS user

半世苍凉 提交于 2019-12-13 00:51:23

问题


I have a WCF service that runs a .bat file. It works on my local system, but I have a problem with running it on the server (Windows server 2012 r2).

I've defined the ANT_HOME variable to server's environment variables and I've added %ANT_HOME%\bin to Path variable.

When I write "ant" to CMD on the server it works! But when I call the wcf service from somewhere, it doesn't work.

I found the following error in the log files:

'ant' is not recognized as an internal or external command,
operable program or batch file.

According to this log, I understand that IIS user cannot use the ANT_HOME variable which is already defined.

What I have tried so far:

  • identity impersonate
  • giving full permission to IIS user

回答1:


What version of IIS are you running? If you are running a version where you can create a separate Application Pool for your service then do so and give this Application Pool an identity that has the right PATH or defines ANT_HOME for that user. I always like adding a Ping type method to all my services so I can ask the service who it is running as and where it is running. It is great for troubleshooting and testing WCF services.



来源:https://stackoverflow.com/questions/31378507/how-to-use-environment-variable-with-iis-user

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!