Requirements:
Click the link in Chrome browser, open IE browser, jump to the specified page and pass the parameters
Solution:
Some applications can start and perform operations by clicking the URL link (e.g. Xunlei). How does this happen? It mainly registers the URL Protocol by modifying the registry.
Phase 1: click the link to open IE browser and pass a single parameter
- New alert reg
Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\alert] @="URL: Alert Protocol" "URL Protocol"="" [HKEY_CLASSES_ROOT\alert\DefaultIcon] @="iexplore.exe,1" [HKEY_CLASSES_ROOT\alert\shell] [HKEY_CLASSES_ROOT\alert\shell\open] [HKEY_CLASSES_ROOT\alert\shell\open\command] @=" cmd /c set m=%1 & call set m=%%m:alert:=%% & call \"C:\\Program Files\\Internet Explorer\\iexplore.exe\" %%m%%"
notes:
set m=%1 (% 1 is the passed parameter, assign it to variable m)
set m=%%m:alert: =%% (clear the prefix alert:)
"C: \ program files \ Internet Explorer \ IExplore. Exe"%% m%% (open IE)
Browser and jump to the specified page)
- Test link:
<a href="alert://www.baidu.com?a=1" />test
- Running result: open IE browser and pass parameter a successfully!
Phase 2: transfer multiple parameters
- Test link:
<a href="alert://www.baidu.com?a=1&b=2" />test
- Running result: parameter b transfer failed!
- Solution: modify alert reg
[HKEY_CLASSES_ROOT\alert\shell\open\command]@="cmd /c set m=%1 & echo 1 Value of:%1 & call echo m Value of:%%m%% & call set m=%%m:alert:=%% & call \"C:\\Program Files\\Internet Explorer\\iexplore.exe\" %%m%% & exit"
-
Running result: parameter b transfer still failed!
-
Cause analysis:
set m=%1, where% 1 will be directly replaced by
alert://www.baidu.com?a=1&b=2 , & the symbol divides it into two commands, m=alert://www.baidu.com?a=1 And B = 2
It seems that the special symbol & cannot be passed directly, so I thought of replacing the & symbol with a custom separator string, and replacing it with the & symbol before passing it to IE.
- Solution: modify alert reg
[HKEY_CLASSES_ROOT\alert\shell\open\command] @="cmd /c set m=%1 & call set m=%%m:alert:=%% & call set m=\"%%m:separator=&%%\" & call \"C:\\Program Files\\Internet Explorer\\iexplore.exe\" %%m%%"
- Test link:
<a href="alert://www.baidu.com?a=1separatorb=2" />test
- Operation effect: parameter b passed successfully!
I thought I could retire with success, but I found a strange phenomenon.
Click the test link OK for the first time, and click the link again without closing ie. the newly popped IE address is wrong, and the effect is as follows:
The address bar changes to: http: / /% 22 / / www.baidu.com com/? a=1&b=2%20%20"
- Solution: modify alert reg
[HKEY_CLASSES_ROOT\alert\shell\open\command] @="cmd /c set m=%1 & call set m=%%m:alert:=%% & call echo First replacement:%%m%% & call set m=\"%%m:separator=&%%\" & call echo Second replacement:%%m%% & call \"C:\\Program Files\\Internet Explorer\\iexplore.exe\" %%m%%"
- Operation result: still not ideal, there is a problem with the transfer parameters
- Cause analysis:
After executing M = \ "%% m: separator = &%% \",
The value of m becomes "/ / www.baidu. COM /? A = 1 & B = 2"
It seems that the problem lies in double quotation marks, but because it contains special characters &, double quotation marks must be used here.
After trying various writing methods without success, under the guidance of the trained expert, write the specific operation into the bat file, and call the bat here.
Create a new alert in C:\Program Files\WisoftAlert directory bat
@echo off set m=%m:alert:=% set m="%m:separator=&%" start "" "C:\\Program Files\\Internet Explorer\\iexplore.exe" %m% exit
- Solution: modify alert reg
[HKEY_CLASSES_ROOT\alert\shell\open\command] @="cmd /c set m=%1 & \"C:\\Program Files\\WisoftAlert\\alert.bat\" %%m%% & exit"
- Running result: multiple clicks on the test link are successful! (sketch)
Stage 3: user-friendly operation
New runreg Bat, automatic registration protocol
REGEDIT /S alert.reg
Alert. Via WinRAR reg,alert.bat,runreg.bat packaged into exe file
The decompression path needs to be consistent with alert Consistent in reg
Run runreg. Automatically after decompression Bat, write registry information
Silent execution
Important!!! Three folders summary!!!
1.alert.reg
Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\openIE] @="URL:alert Protocol" "URL Protocol"="" [HKEY_CLASSES_ROOT\openIE\DefaultIcon] @="iexplore.exe,1" [HKEY_CLASSES_ROOT\openIE\shell] [HKEY_CLASSES_ROOT\openIE\shell\open] [HKEY_CLASSES_ROOT\openIE\shell\open\command] @="cmd /c set m=%1 & \"C:\\Program Files\\WisoftAlert\\alert.bat\" %%m%% & exit"
2.alert.bat
@echo off set m=%m:alert:=% set m="%m:separator=&%" start "" "C:\\Program Files\\Internet Explorer\\iexplore.exe" %m% exit
3.runref.bat
REGEDIT /S openIE.reg
Now it can be used normally. In fact, it can be further optimized (you can try if you want to try)
Phase 4: direct use of & symbols in links
Resolution process:
1. Modify alert bat
@echo off set m=%1% set m=%m:alert:=% start "" "C:\\Program Files\\Internet Explorer\\iexplore.exe" %m% exit
2. Modify alert Reg, enclose parameter% 1 in double quotation marks
[HKEY_CLASSES_ROOT\alert\shell\open\command] @="\"C:\\Program Files\\WisoftAlert\\alert.bat\" \"%1\""
Test link:
<a href="alert://www.baidu.com?a=1&b=2" />test
Test successful!