Str*_*ero 6 windows registry shell cmd batch-file
我正在尝试替换Windows注册表项的一行代码中的子字符串
[HKEY_CLASSES_ROOT\PING\shell\open\command]
@="C:\\Windows\\System32\\ping.exe %1 -t"
Run Code Online (Sandbox Code Playgroud)
场景和背景:
上下文是一个自定义URL协议,它将打开一个shell,持续ping到特定的ip,我想ping://从传递的uri中删除协议%1.确定我可以使用批处理文件,但我更喜欢在注册表中将它全部放在一行中
我尝试过的:
到目前为止,我尝试添加一个命令列表,&设置一个var,然后回显它.
试着 call set remove=ping:// & call set mynewvar=%1:%remove=% & ping.exe %mynewvar% -t
我尝试过使用几次扩展变量 %%
基本上我一直在得到奇怪的结果或替换根本不工作
不确定我做错了什么?打字这个,我开始认为我忽略了它在字符串变量中的事实@="..."
谢谢
注册表项
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\PING]
@="url:ping protocol"
"URL Protocol"=""
[HKEY_CLASSES_ROOT\PING\shell]
[HKEY_CLASSES_ROOT\PING\shell\open]
[HKEY_CLASSES_ROOT\PING\shell\open\command]
@="cmd /k set var=%1 & call set var=%%var:ping://=%% & ping.exe %var% -t"
Run Code Online (Sandbox Code Playgroud)
浏览器输入网址
ping://8.8.8.8
cmd提示输出
Ping request could not find host ping://8.8.8.8/ar. Please check the name and try again.
我注意到arip之后%var%它出现了它使用的%v不是%var
得到它.. %v实际上
%v – For verbs that are none implies all. If there is no parameter passed this is the working directory.
得到了这个答案
工作代码
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\PING]
@="url:ping protocol"
"URL Protocol"=""
[HKEY_CLASSES_ROOT\PING\shell]
[HKEY_CLASSES_ROOT\PING\shell\open]
[HKEY_CLASSES_ROOT\PING\shell\open\command]
@="cmd /k set myvar=%1 & call set myvar=%%myvar:ping:=%% & call set myvar=%%myvar:/=%% & call ping.exe %%myvar%% -t"
Run Code Online (Sandbox Code Playgroud)