China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-04 05:42
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Built-in CHM decompiling function in the system! View 829 Replies 5
Original Poster Posted 2007-04-19 02:35 ·  IANA 局域网IP(Private-Use)
中级用户
★★
Credits 379
Posts 95
Joined 2003-07-17 00:00
23-year member
UID 7038
Gender Male
Status Offline
@echo off
title "Built-in CHM decompiling function in the system!"
echo "Note: there must not be spaces in the chm file!"
echo "Script written by: PeterDocter"
echo "2007-04-18"
path %windir%;%windir%\system32
echo Decompinling...
for /f "tokens=*" %%I in ("%1") do (
rem short Chm filename
set Chm=%%~nxsI
rem create full directory
set ChmDir=%%~nI
rem full path
set ChmPath=%%~dpI
)
rem switch to target path
cd /d %ChmPath%
if not exist "%chmDir%" md "%chmDir%"
rem HH decompile parameters
HH.EXE -decompile %chmDir% %Chm%
echo All files in the %chmDir%!
pause
exit
I want to add a right-click mouse function, but unfortunately I don't know how to do it. Also, when the chm file contains spaces it gets rather troublesome! Please see if anyone can optimize this code a bit?

[ Last edited by peterdocter on 2007-4-19 at 04:38 AM ]
Floor 2 Posted 2007-04-19 02:40 ·  中国 安徽 芜湖 电信
高级用户
★★
Credits 537
Posts 219
Joined 2006-10-31 21:08
19-year member
UID 69036
Gender Male
From 芜湖
Status Offline

@echo off
for %%i in (%1) do (
echo path: %%~dpi
echo filename: %%~nxi
)
pause

For details, see for /?
江湖远
碧空长
路茫茫

一个人漫无目的的奔跑,风,刺骨的冷....
Floor 3 Posted 2007-04-19 03:48 ·  IANA 局域网IP(Private-Use)
中级用户
★★
Credits 379
Posts 95
Joined 2003-07-17 00:00
23-year member
UID 7038
Gender Male
Status Offline
Many thanks! I've already solved it! At the same time, here's one that can decompile chm directly without using other tools!
@echo off
path %windir%;%windir%\system32
echo Decompinling...
for /f "tokens=*" %%I in ("%1") do (
rem short Chm filename
set Chm=%%~nxsI
rem create full directory
set ChmDir=%%~nI
rem decompile short directory
set ChmDe=%%~nsI
rem full path
set ChmPath=%%~dpI
)
rem switch to target path
cd /d %ChmPath%
if not exist "%chmDir%" md "%chmDir%"
rem HH decompile parameters
HH.EXE -decompile %ChmDe% %Chm%
echo All files in the %chmDir%!
pause
exit
Very strange, I found that many commands only work with short paths!
I want to put it into the right-click mouse function, but I don't know how to do it. Is there any related registry information?
Floor 4 Posted 2007-04-19 04:24 ·  中国 四川 成都 联通
中级用户
★★
Credits 346
Posts 103
Joined 2004-04-06 00:00
22-year member
UID 21852
Gender Male
Status Offline
It seems the code from the previous post is a bit too troublesome to write~~
Floor 5 Posted 2007-04-19 04:27 ·  IANA 局域网IP(Private-Use)
中级用户
★★
Credits 379
Posts 95
Joined 2003-07-17 00:00
23-year member
UID 7038
Gender Male
Status Offline
There's still a tiny problem: if there are no spaces in the chm file, it will generate one extra directory!
set ChmDir=%%~nI
set Repace=%ChmDir:空格=为空%
How should the above code be written?
Floor 6 Posted 2007-04-19 05:24 ·  中国 广西 玉林 博白县 电信
金牌会员
★★★★
Credits 3,687
Posts 1,467
Joined 2005-08-08 12:00
20-year member
UID 44210
Status Offline
Only when right-clicking a chm file will the “Decompile CHM” item appear; no need to make another bat file
reg add "HKCR\chm.file\shell\反译 CHM\command" /ve /t reg_sz /d "hh.exe -decompile .\ %%1" /f


[ Last edited by zh159 on 2007-4-18 at 04:28 PM ]
Forum Jump: