“如何使Windows 7不使用可移动驱动器上的回收站?”
在启动或登录时运行以下脚本。
源Windows 7:禁用$ recycle.bin文件夹的创建?:
是的,这是可以做到的……因为我很生气,无法做到这一点,所以我写了一个脚本来做到这一点(见下文)。它对我有用,但是如果您有任何问题,可能需要稍微调整一下。
' Author: HSV Guy
' Description: Script to remove Recycle Bin folder. Run on Windows startup or login.
' Notes: 1) See http://www.sevenforums.com/tutorials/11949-elevated-program-shortcut-without-uac-prompt-create.html
' for how to run programs/scripts with elevated permissions without a UAC prompt.
' 2) Update value of RECYCLEBIN as per version of Windows (configured for Windows 7).
' Date: 1 April 2011
Dim SILENT
SILENT = TRUE
Call RunElevated
Dim filesys, drv, drvcoll, folder, RECYCLEBIN
RECYCLEBIN = ":\$Recycle.Bin\"
Set filesys = CreateObject("Scripting.FileSystemObject")
Set drvcoll = filesys.Drives
For Each drv in drvcoll
If drv.IsReady And filesys.FolderExists(drv.DriveLetter & RECYCLEBIN) Then
Set folder = filesys.GetFolder(drv.DriveLetter & RECYCLEBIN)
MyMsgBox "About to delete: " & folder
folder.Delete
Else
MyMsgBox "Skipped " & drv.DriveLetter & ". Folder doesn't exist or device not ready."
End If
Next
'Source code of RunElevated function shamelessly taken from:
' http://www.insidethe.com/blog/2009/12/how-to-launch-a-wsh-vbscript-as-administrator-in-windows-7-and-vista/
Function RunElevated
If WScript.Arguments.Named.Exists("elevated") = False Then
'Launch the script again as administrator
CreateObject("Shell.Application").ShellExecute "wscript.exe", """" & WScript.ScriptFullName & """ /elevated", "", "runas", 1
WScript.Quit
Else
'Change the working directory from the system32 folder back to the script's folder.
Set oShell = CreateObject("WScript.Shell")
oShell.CurrentDirectory = CreateObject("Scripting.FileSystemObject").GetParentFolderName(WScript.ScriptFullName)
MyMsgBox "Now running with elevated permissions" & SILENT
End If
End Function
Function MyMsgBox(Message)
If Not SILENT Then MsgBox Message
End Function