Showing posts with label windows. Show all posts
Showing posts with label windows. Show all posts

Thursday, October 21, 2010

Basename, Filename, Dirname in Batch

Umm, batch scripts sucks, but here goes:

set filepath="C:\some path\having spaces.txt"

for /F "delims=" %%i in (%filepath%) do set dirname="%%~dpi" 
for /F "delims=" %%i in (%filepath%) do set filename="%%~nxi"
for /F "delims=" %%i in (%filepath%) do set basename="%%~ni"

echo %dirname%
echo %filename%
echo %basename%

I have awed this for crap many times before, now I have it here for the future.

Friday, January 1, 2010

Add your program to "Default Programs" in Windows 7

I wanted to have chromium in "Default Programs", so I can associate HTTP protocol to it, here is how I did that. If you want to do same just change C:\\Program Copies\\Chromium\\chrome.exe to point your chrome.exe, note that is in two places!

For your own program just change the chromium/path etc. to something suitable for your project.

ChromiumToSetDefaults.reg:
Windows Registry Editor Version 5.00

; Infamous capabilities:

[HKEY_LOCAL_MACHINE\SOFTWARE\Chromium\Capabilities]
"ApplicationDescription"="Chromium - Beta Google Chrome"
"ApplicationIcon"="C:\\Program Copies\\Chromium\\chrome.exe,0"
"ApplicationName"="Chromium"

[HKEY_LOCAL_MACHINE\SOFTWARE\Chromium\Capabilities\FileAssociations]
".htm"="ChromiumURL"
".html"="ChromiumURL"
".shtml"="ChromiumURL"
".xht"="ChromiumURL"
".xhtml"="ChromiumURL"

[HKEY_LOCAL_MACHINE\SOFTWARE\Chromium\Capabilities\URLAssociations]
"ftp"="ChromiumURL"
"http"="ChromiumURL"
"https"="ChromiumURL"

; Register to Default Programs

[HKEY_LOCAL_MACHINE\SOFTWARE\RegisteredApplications]
"Chromium"="Software\\Chromium\\Capabilities"

; ChromiumURL HANDLER:

[HKEY_LOCAL_MACHINE\Software\Classes\ChromiumURL]
@="Chromium Document"
"FriendlyTypeName"="Chromium Document"

[HKEY_LOCAL_MACHINE\Software\Classes\ChromiumURL\shell]

[HKEY_LOCAL_MACHINE\Software\Classes\ChromiumURL\shell\open]

[HKEY_LOCAL_MACHINE\Software\Classes\ChromiumURL\shell\open\command]
@="\"C:\\Program Copies\\Chromium\\chrome.exe\" -- \"%1\""