Thursday, August 18, 2005

COPY/MOVE TO Function

Did you ever want to right-click in explorer and simply move or copy file/directory?? Well, now you can. Simply create a new text file called "install_copy_move_to.vbs" and copy/paste the first code below, then create another new text file called "uninstall_copy_move_to.vbs" and copy/paste the second code. Then run "install_copy_move_to.vbs", test it by right-clicking a file or directory in explorer. To uninstall, simply run "uninstall_copy_move_to.vbs".

First Code
Code:

If (MsgBox ("Are you sure you want to install the Copy/Move To Extensions?", VBYesNo) = vbYes) then
Set WshShell = WScript.CreateObject("WScript.Shell")

' Copy uninstall file and Add uninstall reg entry
WinDir = WshShell.ExpandEnvironmentStrings("%Windir%")
Set fso = WScript.CreateObject("Scripting.FileSystemObject")
Call fso.CopyFile("uninstallcopymoveto.vbs", _
WinDir & "\uninstallcopymoveto.vbs", True)
Set fso = Nothing
BaseKey = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Copy Move To Extensions\"
Call WshShell.RegWrite (BaseKey & "DisplayName", _
"Copy/Move To Extensions","REG_SZ")
Call WshShell.RegWrite (BaseKey & "UninstallString", _
"cscript.exe " & WinDir & "\uninstallcopymoveto.vbs" ,"REG_SZ")

' Add Copy/Move Extensions
Call WshShell.RegWrite ("HKCR\Directory\shellex\ContextMenuHandlers\Copy To\", "{C2FBB630-2971-11d1-A18C-00C04FD75D13}" ,"REG_SZ")
Call WshShell.RegWrite ("HKCR\*\shellex\ContextMenuHandlers\Copy To\", "{C2FBB630-2971-11d1-A18C-00C04FD75D13}" ,"REG_SZ")
Call WshShell.RegWrite ("HKCR\Directory\shellex\ContextMenuHandlers\Move To\", "{C2FBB631-2971-11d1-A18C-00C04FD75D13}" ,"REG_SZ")
Call WshShell.RegWrite ("HKCR\*\shellex\ContextMenuHandlers\Move To\", "{C2FBB631-2971-11d1-A18C-00C04FD75D13}" ,"REG_SZ")

Set WshShell = Nothing

MsgBox "Install Finished!"
End If


Second Code
Code:

If (MsgBox ("Are you sure you want to uninstall the Copy/Move To Extensions?", VBYesNo) = vbYes) then
Set WshShell = WScript.CreateObject("WScript.Shell")

' Remove Copy/Move Extensions
Call WshShell.RegDelete ("HKCR\Directory\shellex\ContextMenuHandlers\Copy To\")
Call WshShell.RegDelete ("HKCR\*\shellex\ContextMenuHandlers\Copy To\")
Call WshShell.RegDelete ("HKCR\Directory\shellex\ContextMenuHandlers\Move To\")
Call WshShell.RegDelete ("HKCR\*\shellex\ContextMenuHandlers\Move To\")

' Remove uninstall reg entry and delete uninstall file
BaseKey = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Copy Move To Extensions\"
Call WshShell.RegDelete (BaseKey)

WinDir = WshShell.ExpandEnvironmentStrings("%Windir%")
Set fso = WScript.CreateObject("Scripting.FileSystemObject")
Call fso.DeleteFile(WinDir & "\uninstallcopymoveto.vbs", True)
Set fso = Nothing

Set WshShell = Nothing

MsgBox "Uninstall Finished!"
End If


RESULTS WILL VARY
No matter how good your systems may be, they're only as effective as what you put into them.

0 Comments:

Post a Comment

<< Home

eXTReMe Tracker