「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