' NewFolder.vbs - Create right click context menu item for drives and ' directories (folders) allowing the creation of a new folder. ' To Install or Un-install, double click this file. ' Requires WSH 2.0 + '© Bill James - bill@billsway.com - rev 14/Nov/2001 Option Explicit Dim fso, ws, Args, Title Set fso = CreateObject("Scripting.FileSystemObject") Set ws = CreateObject("Wscript.Shell") Set Args = WScript.Arguments Title = "Herramienta para crear una carpeta nueva" 'Validate correct version for script. If WScript.Version < 5.1 Then ws.Popup "You need Windows Script Host 2.0 + to " & _ "run this script.", , Title, 0 + 48 + 4096 Call Cleanup End If 'If script called directly, check setup & uninstall. If Args.Count = 0 Then Call Setup End If 'Disable multiple drag and drop If Args.Count > 1 Then Call Cleanup End If Dim ParentFldr 'If a file was dragged to script, exit On Error Resume Next Set ParentFldr = fso.GetFile(Args(0)) If Err.Number = 0 Then Call Cleanup End If Set ParentFldr = Nothing On Error GoTo 0 Call MakeNewFolder Call Cleanup Sub MakeNewFolder Dim NewFldr NewFldr = InputBox("¿Nombre de la carpeta?", Title, "Nombre") If NewFldr = "" Then Call Cleanup On Error Resume Next fso.CreateFolder fso.GetFolder(Args(0)) & "\" & NewFldr If Err.Number = 58 Then Err.Clear:On Error GoTo 0 ws.Popup Chr(34) & NewFldr & Chr(34) & " ya existe.", ,Title, 0 + 48 + 4096 Call MakeNewFolder ElseIf Err.Number = 52 Then Err.Clear:On Error GoTo 0 ws.Popup Chr(34) & NewFldr & Chr(34) & " contiene caracteres no válidos.", ,Title, 0 + 48 + 4096 Call MakeNewFolder End If End Sub Sub Setup 'Write Reg Data if not existing or if path is invalid. Dim p On Error Resume Next p = ws.RegRead("HKCR\Folder\shell\NewFolder\command\") p = Mid(p, 10, Len(p) - 15) Err.Clear:On Error GoTo 0 If NOT fso.FileExists(p) Then If ws.Popup("Do you want to Install the Folder context menu for " & _ "creating a new folder?", , Title, 4 + 32 + 4096) <> 6 Then Call Cleanup End If ws.RegWrite "HKCR\Folder\shell\NewFolder\","&Nueva carpeta" ws.RegWrite "HKCR\Folder\shell\NewFolder\command\", _ "WScript " & chr(34) & WScript.ScriptFullName & _ chr(34) & " " & chr(34) & "%1" & chr(34) ws.Popup "Setup complete. Right click on any Drive or Folder in Windows " & _ "Explorer and select the " & chr(34) & "New Folder" & chr(34) & _ " option to create a new folder there." & vbcrlf & vbcrlf & _ "To Un-install, run this script again.", , Title, 64 + 4096 Else If ws.Popup("Do you want to Un-install the Folder context menu for " & _ "creating a new folder?", , Title, 4 + 32 + 4096) <> 6 Then Call Cleanup End If ws.RegDelete "HKCR\Folder\shell\NewFolder\command\" ws.RegDelete "HKCR\Folder\shell\NewFolder\" ws.Popup "Un-install complete.", , Title, 64 + 4096 End If Call Cleanup End Sub Sub Cleanup Set ws = Nothing Set fso = Nothing Set Args = Nothing WScript.Quit End Sub