windows – CMD / Batch / Registry – 字符串替换不按预期工作
我正在尝试替换
Windows注册表项的一行代码中的子字符串
[HKEY_CLASSES_ROOTPINGshellopencommand] @="C:WindowsSystem32ping.exe %1 -t" 场景和背景: 上下文是一个自定义URL协议,它将打开一个shell,连续ping到特定的ip,我想从uri中删除协议ping://作为%1传递. 我尝试过的: 到目前为止,我已经尝试用&添加一个命令列表.设置var然后回显它.. 尝试过call set remove = ping://& call set mynewvar =%1:%remove =%& ping.exe%mynewvar%-t 我尝试使用%%扩展变量几次 基本上我一直在得到奇怪的结果或替换根本不工作 不确定我做错了什么?输入这个,我开始认为我忽略了它在字符串var @ =“……”中的事实. 谢谢 注册表项 Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOTPING] @="url:ping protocol" "URL Protocol"="" [HKEY_CLASSES_ROOTPINGshell] [HKEY_CLASSES_ROOTPINGshellopen] [HKEY_CLASSES_ROOTPINGshellopencommand] @="cmd /k set var=%1 & call set var=%%var:ping://=%% & ping.exe %var% -t" 浏览器输入网址 cmd提示输出 我注意到ip来自%var%之后,它出现了它使用%v而不是%var 解决方法
得到它..%v实际上
%v – 对于没有暗示全部的动词.如果没有传递参数,那么这是工作目录. 从this answer得到了 工作代码 Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOTPING] @="url:ping protocol" "URL Protocol"="" [HKEY_CLASSES_ROOTPINGshell] [HKEY_CLASSES_ROOTPINGshellopen] [HKEY_CLASSES_ROOTPINGshellopencommand] @="cmd /k set myvar=%1 & call set myvar=%%myvar:ping:=%% & call set myvar=%%myvar:/=%% & call ping.exe %%myvar%% -t" (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- windows-7 – Windows 7 64位上的FoxPro 2.6 DOS
- windows – 为什么单击子窗口并不总是将应用程序带到前台?
- winapi – Windows API中有哪些定期计时器对象?
- windows-server-2008 – RemoteApp:以用户x身份登录,断开用
- win10 0x8007042b 安装1803更新 失败 竟然是sougou 搜狗拼音
- windows-8 – 可以在WinRT中创建IME吗?
- Windows防火墙编程
- Windows 7入门OpenCL
- AutoHotKey:如何禁用Skype热键并使键盘正常运行
- 如何在Windows 2012 RDP中禁用TLS 1.0
- NTFS更改日记帐大小
- windows – 在程序文件文件夹上安装有多重要?
- windows mercurial 2.5(或将来)上的unicode文件名
- windows-server-2008 – LDAP身份验证:Windows
- Hewlett Packard定制OEM Windows上的Delphi平台错
- windows-server-2003 – 可以重命名私有MSMQ队列
- windows-server-2008 – 计划任务在Windows Serv
- windows-server-2003 – 将Windows Server 2012域
- unit-testing – mstest.exe如何处理测试DLL的配
- 调试 – 如何使用ILspy调试一个DLL?