在Windows registery命令中修剪变量

时间:2018-12-04 05:21:53

标签: batch-file cmd

我有以下Windows注册表。

[HKEY_CURRENT_USER\Software\Classes\adIELaunch]
@="URL:adIELaunch Protocol"
"URL Protocol"=""

[HKEY_CURRENT_USER\Software\Classes\adIELaunch\DefaultIcon]
@="C:\\Program Files (x86)\\Internet Explorer\\iexplore.exe,1"

[HKEY_CURRENT_USER\Software\Classes\adIELaunch\shell]

[HKEY_CURRENT_USER\Software\Classes\adIELaunch\shell\open]

[HKEY_CURRENT_USER\Software\Classes\adIELaunch\shell\open\command]
@="\"C:\\Program Files (x86)\\Internet Explorer\\iexplore.exe\" \"%1\""

我想使用URL adIELaunch:http://example.com启动Internet Explorer。 此处的IE会以adIELaunch:http://example.com打开。 但是,我希望IE仅使用URL来启动,即要修剪协议名称“ adIELaunch”。

到目前为止,我已经尝试过:

 @="\"C:\\Program Files (x86)\\Internet Explorer\\iexplore.exe\" \"%1:~0,11%\""

我想从网址中修剪“ adIELaunch:”。

1 个答案:

答案 0 :(得分:0)

如问题评论中@LotPings所述,传递参数时无法进行修整。

因此,我设法通过将参数传递给CMD来执行此操作,然后对CMD命令执行序列以实现此目的。

下面是代码段。

[HKEY_CURRENT_USER\Software\Classes\ADIELaunch\shell\open\command]
@="cmd /C set externalURL=\"%1\"& call set externalURL=%%externalURL:ADIELaunch:=%%& call start \"\" /separate \"C:\\Program Files (x86)\\Internet Explorer\\iexplore.exe\" %%externalURL%%&exit"