Monday, August 20, 2007

Windows USB thumb drive scripts

This batch file adds right click context menu for all files. So, you can drag and drop gvim.exe to the batch file and have gvim context menu for all files. If it doesn't work, it'll at least create addcontext.reg file to the folder the executable is located. Go to the folder and double click addcontext.reg

@echo off
setlocal
set app_name=%~n1
set app_abs=%~f1
set app=%app_abs:\=\\%
set command=@="%app% \"%%1\""
set workingdir="%~dp0"
set regname=%workingdir%\addcontext.reg
echo Windows Registry Editor Version 5.00 > %regname%
echo. >> %regname%
echo [HKEY_CURRENT_USER\Software\Classes\*\shell] >> %regname%
echo. >> %regname%
echo [HKEY_CURRENT_USER\Software\Classes\*\shell\%app_name%] >> %regname%
echo. >> %regname%
echo [HKEY_CURRENT_USER\Software\Classes\*\shell\%app_name%\command] >> %regname%
echo %command% >> %regname%
regedit.exe /s %regname%
echo %app_name% context menu installed
endlocal
pause

Run this reg file to remove the context menu:

Windows Registry Editor Version 5.00

[-HKEY_CURRENT_USER\Software\Classes\*\shell]

This reg file adds opencmd context menu to folders that opens cmd.exe on that folder:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Classes\Folder\shell]

[HKEY_CURRENT_USER\Software\Classes\Folder\shell\opencmd]

[HKEY_CURRENT_USER\Software\Classes\Folder\shell\opencmd\command]
@="Cmd.exe /k pushd %L"

Run this reg file to remove opencmd context menu:

Windows Registry Editor Version 5.00

[-HKEY_CURRENT_USER\Software\Classes\Folder\shell]

No comments:

Post a Comment