Clearing out "temporary asp.net files"

本文介绍了一种通过批处理文件自动清除ASP.NET临时文件的方法,并重新设置必要的权限,确保每次测试都有干净一致的环境。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

When I am testing out issues with ASP.NET dynamic compilation and shadow copying, I frequently need to ensure the contents of the "temporary asp.net files" folder have been removed so that I get a clean and consistent repro each time.

Normally I just do an IISRESET /STOP, delete the files manually and then do an IISRESET /START.

But I got bored of that so thought I would try to automate it with a command file.

First thought was to do a DEL /S "C:/WINDOWS/Microsoft.NET/Framework/v1.1.4322/Temporary ASP.NET Files/*.*"

This worked, but left the directory structure in place.

So my next thought was to do an RMDIR /S /Q "C:/WINDOWS/Microsoft.NET/Framework/v1.1.4322/Temporary ASP.NET Files" and then just recreate the directory.

That certainly left me with an empty directory, BUT, the "NETWORK SERVICE" account under which my application pools usually run had no permissions to the newly created folder, so I got an "access denied" error as soon as I tried to browse an ASP.NET page.

Then I thougt I'd get clever and use the built in command line tool CACLS.EXE to give full control permissions to the built in IIS_WPG local group of which NETWORK SERVICE is a paid up member. (Any account you use as the identity for an application pool should be added to IIS_WPG rather than trying to give the account all the needed permissions directly. It's much simpler and more maintainable.)

What I didn't like about that was that CACLS.EXE does not appear to support a way of suppressing the "are you sure (Y/N)?" prompts.

So finally I grabbed a copy of XCACLS.VBS and got the following command file working:

 

iisreset /stop
rmdir /q /s "C:/WINDOWS/Microsoft.NET/Framework/v1.1.4322/Temporary ASP.NET Files"
rmdir /q /s "C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files"
md "C:/WINDOWS/Microsoft.NET/Framework/v1.1.4322/Temporary ASP.NET Files"
md "C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files"
xcacls "C:/WINDOWS/Microsoft.NET/Framework/v1.1.4322/Temporary ASP.NET Files" /E /G MYMACHINE/IIS_WPG:F /Q
xcacls "C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files" /E /G MYMACHINE/IIS_WPG:F /Q
iisreset /start

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值