# [qutebrowser] How to run a userscript in Windows

Florian Bruhin me at the-compiler.org
Mon Sep 5 10:27:08 CEST 2016

Hey,

I re-added the mailinglist in your reply, as you wrote to me directly
;)

* David Nebauer <davidnebauer3 at bigpond.com> [2016-09-03 00:19:17 +0930]:
> > * Daniel Schadt <daniel at kingdread.de> [2016-08-31 22:36:47 +0200]:
> > > > command called: spawn ['--userscript', 'SCRIPT.py']
> > > So as far as I can tell, the only things you can run on
> > > Windows as (user)script are native .exe and .bat/.cmd files.
> > >
> > > So to solve this, you can either use
> > >      "\path\to\python.exe \path\to\script.py"
> > > as command for spawn (without the --userscript flag), or you can write
> > > a simple .bat file that just calls your real userscript under the hood.
>
> I tried using bat/cmd userscripts as wrappers that call the python script
> but nothing worked, so I tried the simplest possible case -- 'hello.bat' in
> the userscript directory containing a single line:
>
>         Echo message-info "Hello from a userscript!" >> "%QUTE_FIFO%"
>
> Calling userscript hello or hello.bat resulted in the same failure I
> reported for the python script. Here are the log messages for one example:

Hmm, that's odd. Can you open an issue at
https://github.com/The-Compiler/qutebrowser so I can take a look at it
whenever I next feel like dealing with Windows stuff? ;)
>
>     command called: spawn ['--userscript', 'hello.bat']
> [...]
>     Userscript to run:
> C:\Users\ME\AppData\Local\qutebrowser\data\userscripts\hello.bat

I'm guessing the hello.bat is in that location?

>     Error while spawning userscript: The process failed to start.

Unfortunately that's all Qt (and probably the Windows API) can give
us... It usually means the file is not at that location, or not
executable.

> It's not a quoting problem; running the bat file from a dos prompt worked
> fine if I first set QUTE_FIFO to a dummy file name. It created a file
> containing the correctly quoted command:
>
>         message-info "Hello from a userscript!"
>
> So now I'm wondering if the userscript mechanism works at all in windows.
> Has anyone ever run a userscript in windows successfully? If so, can someone
> post an example? If I start with something that works I may be able to build
> it up to run my python script.
>
> Please note, it's not enough to simply execute a bat/cmd/exe file; it has to
> execute in an environment where the userscript variables (QUTE_FIFO, etc.)
> are available to the userscript.

FWIW the qutebrowser testsuite doesn't run an userscript on Windows,
but I don't remember why that was.

Florian

--
http://www.the-compiler.org | me at the-compiler.org (Mail/XMPP)
GPG: 916E B0C8 FD55 A072 | http://the-compiler.org/pubkey.asc
I love long mails! | http://email.is-not-s.ms/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <https://listi.jpberlin.de/pipermail/qutebrowser/attachments/20160905/ace36d4c/attachment.asc>
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.721524715423584, "perplexity": 14066.292277304952}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.3, "absolute_threshold": 20, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2022-33/segments/1659882572198.93/warc/CC-MAIN-20220815175725-20220815205725-00730.warc.gz"}