开发者

IIS is unable to run "net use" command in a batch file

We have a CMS application that used to be able to run all the commands in a batch file; however, it has been failing in the last week.

For testing, we have modified the contents in the batch file like this:

echo starting > c:\log.txt
whoami >> c:\log.txt
net use Z:\ \\192.168.2.123\share\ password /user:userWithAdminRightsInTarget    
copy c:\aTestFile.txt Z:\Success.txt
net use Z:/DELETE

Let's say ComputerSource is the computer where IIS is hosting the CMS website and where the batch file resides, and ComputerTarget is the computer where I want to copy the files to.

If I run the batch file manually by double clicking it, all commands are run successfully; the result of whoami in c:\log.txt displays the 开发者_JS百科user account that is logged into the server, and the file is copied successfully.

However, if I run the batch file from the CMS website, it executes the first line "echo starting > c:\log.txt" but fails afterwards.

Both commputers are part of a domain We have tested the application by using different domain names, even domain admin accounts. We have used impersonation in the website (specified in web.config file of cms website) as well as using domain admin accounts in IIS directory security. The result of the whoami command when the batch file is run from the website is nt/network service. We have practically tried almost anything.

We will really appreciate for any insights and help that anyone can provide.

Thank you.


You need to change the user identity attached to the application pool of this particular website to an account that has these permissions. Basically the same account you are impersonating with in the web.config must also be specified as the running identity of the site's application pool.


Or maybe call the batch file with a Runas command so you can specify the user it will impersonate?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜