Answer the question
In order to leave comments, you need to log in
Why is the space character handled with an error in Javascript?
Good afternoon, I ran into a problem when creating my own protocol URI
Namely, it is necessary that links of the explorer:// type be opened as if by an explorer, in other words, the content of the link after explorer:// was sent to the explorer as a context
. Thus, a registry entry was created describing the new protocol, and the purpose of this entry was to describe the action of the system / browsers when clicking on this link, the action was as follows:
mshta javascript:new(ActiveXObject)('WScript.Shell').Run(decodeURIComponent(escape('%1'.substr(9)))),window.close()
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\SOFTWARE\Classes\explorer]
"URL Protocol"=""
@="Explorer"
[HKEY_CURRENT_USER\SOFTWARE\Classes\explorer\shell]
[HKEY_CURRENT_USER\SOFTWARE\Classes\explorer\shell\open]
[HKEY_CURRENT_USER\SOFTWARE\Classes\explorer\shell\open\command]
@="mshta javascript:new(ActiveXObject)('WScript.Shell').Run(decodeURIComponent(escape('%1'.substr(9)))),window.close()"
<a href="explorer:\\\\DESKTOP-9NVI47I\\temp\\word">word</a>
<a href="explorer:\\\\DESKTOP-9NVI47I\\temp\\кириллица">кириллица</a>
<a href="explorer:\\\\DESKTOP-9NVI47I\\temp\\файл-с-(кириллицей).txt">файл-с-(кириллицей).txt</a>
<a href="explorer:\\\\DESKTOP-9NVI47I\\temp\\один пробел">один пробел</a><br>
mshta javascript:new(ActiveXObject)('WScript.Shell').Run(alert(decodeURIComponent(escape('%1'.substr(9))))),window.close()
Answer the question
In order to leave comments, you need to log in
I would venture to suggest that spaces in WScript.Shell.Run play the same role they play in cmd - separating command line options. Try using quotes for escaping, i.e.
mshta javascript:new(ActiveXObject)('WScript.Shell').Run('"'+decodeURIComponent(escape('%1'.substr(9)))+'"'),window.close()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question