Launch .bat files from a custom URL handler withou

2019-07-16 04:15发布

问题:

I registered a custom URL handler in Windows, in order to be able to launch a local program from an URL. Following the MSND documentation, I inserted the following values in the Registry:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\TestLaunch]
@="URL:TestLaunch Protocol"
"URL Protocol"=""

[HKEY_CLASSES_ROOT\TestLaunch\DefaultIcon]
@="\"c:\\temp\\test.bat\""

[HKEY_CLASSES_ROOT\TestLaunch\shell]

[HKEY_CLASSES_ROOT\TestLaunch\shell\open]

[HKEY_CLASSES_ROOT\TestLaunch\shell\open\command]
@="\"c:\\temp\\test.bat\" %1"

This works, but when I click a TestLaunch: link and the batch file starts I can see the console windows appearing. Since the role of the batch file is just parsing the argument url and launching another application, I would like the console non to appear (or at least being minimized), even if it is just for a fraction of a second.

The only thing that came to my mind is creating a link to the batch file (test.bat.lnk) and set it to start as minimized, but that won't work. Any other ideas ? I'm open to an alternative to batch files, but I'd like to stick to what Windows provides

回答1:

You could use VBS?

@="\"WSCRIPT c:\\temp\\test.vbs\" %1"

Using

if wscript.arguments.length > 0 then
     wscript.createobject( "WScript.Shell" ).run("app.exe " & wscript.arguments(0))
end if


回答2:

Some workarounds can be found here:

https://superuser.com/questions/62525/run-a-completly-hidden-batch-file

Launch a program from command line without opening a new window

http://www.tomshardware.co.uk/forum/245566-45-batch-file-window-poping

http://www.joeware.net/freetools/tools/quiet/index.htm

http://www.ntwind.com/software/hstart.html