简体   繁体   English

远程重置IIS

[英]reset IIS remotely

I'm going to reset IIS through a batch file. 我将通过批处理文件重置IIS。 Using iisreset utility, as the batch file will be used by others who may log in the domain without the administrator account of the target server. 使用iisreset实用程序,因为该批处理文件将由其他可能会在没有目标服务器管理员帐户的情况下登录域的人使用。 How can I make the batch script running with proper permission? 如何在具有适当权限的情况下运行批处理脚本? Thanks in advance! 提前致谢!

And I also don't want to prompt the user to type in username/password as the batch file will be called by other programs. 而且我也不想提示用户输入用户名/密码,因为批处理文件将被其他程序调用。

Problem 1: Resetting remotely from batch. 问题1:从批处理远程重置。 I prefer sc.exe 我更喜欢sc.exe

Example

sc \\webserver stop w3svc
sc \\webserver start w3svc

SC is not as heavy as IISRESET. SC不如IISRESET重。 Actually, I prefer to use WMI to recycle application pools, but that is tricky to do through batch 实际上,我更喜欢使用WMI来回收应用程序池,但是通过批处理很难做到

Problem 2: Allow users who are not Administrators on the target server to reset IIS. 问题2:允许不是目标服务器管理员的用户重置IIS。

You are either going to have to grant these users (or their group) permissions to control the services or store credentials somewhere. 您将不得不授予这些用户(或他们的组)权限来控制服务或将凭据存储在某个地方。 To grant the minimum permissions, see this KB -- a lot of work. 要授予最低权限,请参阅此知识库 -很多工作。

If you don't grant those executing the batch permission to restart services, see Rusell's answer -- create a WCF service. 如果您不授予执行批处理的人员重新启动服务的权限,请参阅Rusell的答案 -创建WCF服务。

You could create a windows service (using .net WCF for example) that executes this command. 您可以创建执行此命令的Windows服务(例如,使用.net WCF)。 Then the service can run using credentials with administrator access. 然后,可以使用具有管理员访问权限的凭据来运行该服务。

Your other programs can call this service remotely. 您的其他程序可以远程调用此服务。

"iisreset computername " will reset the IIS server if they have admin rights on computername . 如果“ iisreset computername ”具有对computername的管理权限,则将重置IIS服务器。 While I'm not sure how to change the user account in a batch file, this could be a security issue as batch files (as I'm sure you are aware) are stored in plain text. 虽然我不确定如何在批处理文件中更改用户帐户,但这可能是一个安全问题,因为批处理文件(如您所知)以纯文本格式存储。

PS. PS。 This would probably be better on ServerFault 这在ServerFault上可能会更好

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM