I know this is an old post, but I had this exact problem today.
Basically a JxBrowser instance launced by a third party application was returning a http error 401 when it was supposed to open a login window.
This happened on all our domain PC's and the provider was not very helpful in finding a solution.
Seeing as I was basically on my own, I needed to pass a --remote-debugging-port parameter to the chromium executable so I could actually get this resolved
Anyway here is the solution I came up with. It's very hacky, but it works
I first tried creating a .bat file that just runs the input along with the added parameter like below
> @echo off
> %* -bar
I then created a debugger key calling this bat file in the "Image File Execution Options" like below
> reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\foo.exe" /v Debugger /t REG_SZ /d "C:\Path\To\This\batch\file.bat" /f
What this does is everytime Foo.exe is launched it actually runs the command '"C:\Path\To\This\batch\file.bat" Foo.exe',
which in turn runs the command 'Foo.exe -bar'. This means that calling 'Foo.exe -foobar' would result in 'Foo.exe -foobar -bar' being called instead
The problem I then ran into is that because the batch script calls Foo.exe, it actually calls itself in an endless loop, everytime adding -bar to the command so you actually end up running
"C:\Path\To\This\batch\file.bat" Foo.exe -foobar -bar -bar -bar -bar -bar -bar -bar -bar -bar -bar -bar -bar -bar -bar -bar -bar etc."
What I ended up doing was modifying the script to delete the debugger registry key before launching foo.exe and then re-adding it, like so:
> @echo off
> reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\foo.exe" /v Debugger /f
> %* -bar
> reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\foo.exe" /v Debugger /t REG_SZ /d "C:\Path\To\This\batch\file.bat" /f
This results in the following:
- Application attempts to launch 'Foo.exe -foobar'
- Instead of launching Foo.exe, '"C:\Path\To\This\batch\file.bat"
Foo.exe -foobar' is called instead
- The batch script deletes the debugger registry key
- When Foo.exe is called on the next line it actually launches foo.exe
with the added -bar parameter instead of the .bat file
- The registry key is re-added so that the next time Foo.exe is
launched, it will once more run it through the batch script and add
the -bar parameter
(you might have to edit the permissions of the "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\foo.exe" key, so that the application calling foo.exe actually has permission to edit it)
I'm certain there's a better solution to this, but I for the life of me could not find one.