Plamdi Posted October 20, 2006 Share Posted October 20, 2006 Remember my Image-Conversion Shell Extension? No?Well here are two more shell extensions written by yours truly. Both are fully uninstallable from "add/Remove Programs". Enjoy them!Name: Directory UsageReuirements: Windows NT (2000,XP,etc), and a commandline tool from Sysinternals called "Du".Description: Adds a handy context-menu item to display directory (folder) usage. Information loads in Notepad, and includes the number of files, directories and the size it occupies in bytes.Code (save as DIRINFO.VBS):' (c) 2006 plamdi.com, this file must not be sold, you may distribute it' freely so long as it remains unmodified with all internal documentation.' Use this file with Du from Sysinternals. Copy Du.exe to %WINDIR%\SYSTEM32,' and then run this file to install the shell extension. You may now right click any' directory (folder) to view it's disk usage.Option Explicit:On Error Resume NextDim WshShell,fso,f,o,p,t,v,w,tmp:w=0Set WshShell=WScript.CreateObject("WScript.Shell")Set fso=CreateObject("Scripting.FileSystemObject")p=Left(WScript.ScriptFullName,Len(WScript.ScriptFullName)-Len(WScript.ScriptName))If Wscript.Arguments.Count=1 Then If Wscript.Arguments(0)="/REM" Then v=MsgBox("Are you sure you want to remove the directory-information shell extension?",292,"Remove shell extension confirmation") If v=7 Then WshShell=Nothing:Wscript.Quit(1) w=7 ElseIf UCase(Wscript.Arguments(0))="/S" Or UCase(Wscript.Arguments(0))="/SILENT" Then w=6 Else tmp=fso.GetSpecialFolder(2)&"\"&fso.GetTempName WshShell.Run("cmd /c du -q """&Wscript.Arguments(0)&""">"""&tmp&""""),0,True Set f=fso.OpenTextFile(tmp,1) o="Directory Information For:"&vbCrLf&Wscript.Arguments(0)&vbCrLf&vbCrLf&f.ReadAll f.Close fso.DeleteFile(tmp) Set f=fso.CreateTextFile(tmp, True):f.Write o:f.Close WshShell.Run("Notepad """&tmp&""""),1,True fso.DeleteFile(tmp) Set WshShell=Nothing Wscript.Quit(1) End IfElseIf Wscript.Arguments.Count<>0 Then ErrHndlr()End IfIf fso.fileexists(p&"du.exe") Then If UCase(WScript.ScriptFullName)<>UCase(p&"DIRINFO.VBS") Then fso.CopyFile WScript.ScriptFullName,p&"dirinfo.vbs" End IfElse If fso.fileexists(WshShell.Environment("PROCESS")("SystemRoot")&"\System32\du.exe") Then p=WshShell.Environment("PROCESS")("SystemRoot")&"\System32\" fso.CopyFile WScript.ScriptFullName,p&"dirinfo.vbs" Else If w=6 Then WshShell=Nothing:Wscript.Quit(0) ElseIf w<>7 Then v=MsgBox("Du not found. Would you like to remove the shell extension?",292,"Remove shell extension") If v=7 Then WshShell=Nothing:Wscript.Quit(1) End If End IfEnd IfIf w=0 Then w=MsgBox("Do you want the directory-information shell extension?",292,"Enable/Disable shell extension")t="HKCR\Folder\shell\show_dir_usage\"If w=6 Then WshShell.RegWrite t,"Show Directory Usage" WshShell.RegWrite t&"command\","WScript.exe """&p&"dirinfo.vbs"" ""%d"""Else WshShell.RegDelete t&"command\":WshShell.RegDelete tEnd Ift="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\dirinfo\"If w=6 Then WshShell.RegWrite t,"" WshShell.RegWrite t&"DisplayName","Directory Information Shell Extension (Removal)" WshShell.RegWrite t&"UninstallString","WScript.exe """&p&"dirinfo.vbs"" /REM" WshShell.RegWrite t&"NoModify",1,"REG_DWORD" WshShell.RegWrite t&"NoRepair",1,"REG_DWORD"Else WshShell.RegDelete t&"NoModify":WshShell.RegDelete t&"NoRepair" WshShell.RegDelete t&"UninstallString":WshShell.RegDelete t&"DisplayName":WshShell.RegDelete t fso.DeleteFile(p&"dirinfo.vbs")End IfSet WshShell=NothingWscript.Quit(1)sub ErrHndlr() MsgBox "Invalid parameters were given. The only correct user command line is /s or /silent.",16,"dirinfo.vbs error" Set WshShell=Nothing Wscript.Quit(0)End SubName: Quick Find Reuirements: Windows NT (2000,XP,etc) Description: Adds a cheap-and-nasty search feature to all folders, so you can right click and select "Quick Find" - this will search just that directory, and it's subdirectories. Code (save as QFIND.VBS):' (c) 2006 plamdi.com, this file must not be sold, you may distribute it ' freely so long as it remains unmodified with all internal documentation.' Wildcards not supported, just type in the search as a logical filename. ' Example: File.Ext ' You do not need to specify file extension, it is optional. Option Explicit:On Error Resume NextDim WshShell,fso,f,o,p,t,v,w,tmp:w=0Set WshShell=WScript.CreateObject("WScript.Shell")Set fso=CreateObject("Scripting.FileSystemObject")p=Left(WScript.ScriptFullName,Len(WScript.ScriptFullName)-Len(WScript.ScriptName))If Wscript.Arguments.Count=1 Then If Wscript.Arguments(0)="/REM" Then v=MsgBox("Are you sure you want to remove the quick find shell extension?",292,"Remove shell extension confirmation") If v=7 Then WshShell=Nothing:Wscript.Quit(1) w=7 ElseIf UCase(Wscript.Arguments(0))="/S" Or UCase(Wscript.Arguments(0))="/SILENT" Then w=6 Else w=LCase(InputBox("Searching Folder "&Wscript.Arguments(0)&"."&vbCrLf&vbCrLf&"Enter a partial filename to search for below, do not use wildcards.","Quick Find")) If w="" Then Wscript.Quit(0) v=InStrRev(w,".") If v<>1 Then If v=0 Then t="|find """&w&"""" Else t="|find """&Left(w,v-1)&"""" End If Else t="" End If If v<>0 And v<>Len(w) Then v="|find """&Right(w,Len(w)-v+1)&"""" Else v="" End If tmp=fso.GetSpecialFolder(2)&"\"&fso.GetTempName WshShell.Run("cmd /c dir/a/b/s/oe/l """&Wscript.Arguments(0)&""""&t&v&">"""&tmp&""""),0,True Set f=fso.GetFile(tmp) If f.Size<>0 Then WshShell.Run("Notepad """&tmp&""""),1,True Else WScript.Echo "File Not Found." End If fso.DeleteFile(tmp) Set f=Nothing Set WshShell=Nothing Wscript.Quit(1) End IfElseIf Wscript.Arguments.Count<>0 Then ErrHndlr()End Ifp=WshShell.Environment("PROCESS")("SystemRoot")&"\System32\"fso.CopyFile WScript.ScriptFullName,p&"qfind.vbs"If w=0 Then w=MsgBox("Do you want the quick find shell extension?",292,"Enable/Disable shell extension")t="HKCR\Folder\shell\qfind\"If w=6 Then WshShell.RegWrite t,"Quick Find" WshShell.RegWrite t&"command\","WScript.exe """&p&"qfind.vbs"" ""%d"""Else WshShell.RegDelete t&"command\":WshShell.RegDelete tEnd Ift="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\qfind\"If w=6 Then WshShell.RegWrite t,"" WshShell.RegWrite t&"DisplayName","Quick Find Shell Extension (Removal)" WshShell.RegWrite t&"UninstallString","WScript.exe """&p&"qfind.vbs"" /REM" WshShell.RegWrite t&"NoModify",1,"REG_DWORD" WshShell.RegWrite t&"NoRepair",1,"REG_DWORD"Else WshShell.RegDelete t&"NoModify":WshShell.RegDelete t&"NoRepair" WshShell.RegDelete t&"UninstallString":WshShell.RegDelete t&"DisplayName":WshShell.RegDelete t fso.DeleteFile(p&"qfind.vbs")End IfSet WshShell=NothingWscript.Quit(1)sub ErrHndlr() MsgBox "Invalid parameters were given. The only correct user command line is /s or /silent.",16,"qfind.vbs error" Set WshShell=Nothing Wscript.Quit(0)End Sub Link to comment Share on other sites More sharing options...
bucketbuster Posted October 28, 2006 Share Posted October 28, 2006 Nice Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now