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-12 12:34
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Question about getting the current path under XP View 1,115 Replies 4
Original Poster Posted 2010-04-24 00:20 ·  中国 安徽 宿州 泗县 电信
银牌会员
★★★
Credits 1,339
Posts 595
Joined 2004-05-26 00:00
22-year member
UID 25306
Gender Male
From 安徽 宿州
Status Offline
I want to write a batch file that adds a function in the registry to open a file with WinHex from the right-click menu.

The content is as follows:
reg add "HKEY_CLASSES_ROOT\*\shell\WinHex 编辑\command"

/ve /d (the path where Winhex is located)\Winhex.exe "%1"
The batch file and Winhex.exe are in the same folder.

My question is: how can this be done with a batch file?

[ Last edited by chujiafu on 2010-4-24 at 00:21 ]
Floor 2 Posted 2010-04-24 00:27 ·  中国 陕西 西安 电信
铂金会员
★★★★
Credits 5,212
Posts 2,478
Joined 2007-02-08 23:39
19-year member
UID 79003
Gender Male
Status Offline
%cd% current working directory

%~dp0 the path where the batch file is located
S smile 微笑,L love 爱,O optimism 乐观,R relax 放松,E enthusiasm 热情...Slore
Floor 3 Posted 2010-04-24 00:56 ·  中国 北京 联通
高级用户
★★★
据说是李先生
Credits 609
Posts 400
Joined 2008-04-23 15:55
18-year member
UID 116706
Gender Male
Status Offline
This problem bothered me for a long time too. It wasn't until one day when I manually added it in regedit and then exported it as a reg file, observed it, and tried again, that I finally succeeded.

The quotation marks (") have to be handled with the registry escape character, the backslash (\).


@echo off
reg add "HKEY_CLASSES_ROOT\*\shell\WinHex 编辑\command" /ve /d "\"%cd%\Winhex.exe\" \"%%1\""
pause
Floor 4 Posted 2010-04-24 07:52 ·  中国 安徽 宿州 泗县 电信
银牌会员
★★★
Credits 1,339
Posts 595
Joined 2004-05-26 00:00
22-year member
UID 25306
Gender Male
From 安徽 宿州
Status Offline
Many thanks to the two posters above, it worked.
Floor 5 Posted 2010-04-24 10:17 ·  中国 重庆 开州区 移动
初级用户
★★
Credits 90
Posts 57
Joined 2010-04-12 13:29
16-year member
UID 164386
Gender Male
Status Offline
Thanks for sharing
Forum Jump: