1
I use multiple browsers, and I created a bash script that checks to see which browser is open and opens web pages in whatever browser is already open. I use Windows 7, so I run this script using Cygwin. I set the script as the default browser by editing the appropriate registry entries, so whenever any program tries to open a web page, it calls this script using Cygwin's "--login" parameter. The script works - pages get loaded in whatever browser is open. However, whenever the script is called by another program, I get the error message, "There was a problem sending the command to the program." The script works, but I get the error message anyway. This only happens when the script is called by another program - there's no error message if I run the script directly from the command line.
I don't know if the script is at fault, but here it is:
#! /bin/bash
if ps -W | grep -v grep | grep waterfox.exe >/dev/null
then
"/cygdrive/c/Program Files/Waterfox/waterfox.exe" -requestPending -osint -url "$1"
elif ps -W | grep -v grep | grep firefox.exe >/dev/null
then
"/cygdrive/c/Program Files (x86)/Mozilla Firefox/firefox.exe" -requestPending -osint -url "$1"
elif ps -W | grep -v grep | grep chrome.exe >/dev/null
then
"/cygdrive/c/Users/Morgan/AppData/Local/Google/Chrome/Application/chrome.exe" -- "$1"
else
cygstart "/cygdrive/c/Program Files/Waterfox/waterfox.exe" -requestPending -osint -url "$1"
fi
exit
I tried changing the last line to "exit 0" on the theory that there was some problem with the exit status, but that had no effect.
I'd really appreciate it if someone wiser in the ways of Cygwin and/or Windows could enlighten me. Thanks!
I can't get this to work, unfortunately. It ran without a hitch when I ran it manually from the command line, but after adding it to the appropriate registry entries it didn't work. I got different errors when it was called by different programs this time, but they were all some variation on "application not found". (And unlike with the bash script, the script actually failed to open the web pages.) Thanks for trying, though! – Morgan May – 2013-01-10T15:46:14.697
1@MorganMay Try specifying the full path to PowerShell:
C:\Windows\System32\WindowsPowerShell\v1.0\PowerShell.exe
– Aluísio A. S. G. – 2013-01-10T23:03:33.970Changing the registry entries to use the full path fixed the "application not found" error. However, now the PowerShell script behaves exactly the way the bash script did: it successfully opens web pages, but generates the same error as before: "There was a problem sending the command to the program." So I guess that rules out bash/Cygwin as the source of the problem, at least. – Morgan May – 2013-01-11T05:47:25.690
Yes, that's not the problem then. Does this happens with all the browsers? – Aluísio A. S. G. – 2013-01-11T05:59:38.820
Yes, it does. I get the same error messages regardless of which browser is in use. – Morgan May – 2013-01-11T06:20:37.133
Hmm. I think it may not be a problem in the scripts, after all. How are you registering it as default browser? – Aluísio A. S. G. – 2013-01-11T06:26:32.770
I set the registry keys "HKEY_USERS\S-1-5-21-3631097902-1330344798-4155269109-1000_Classes\http\shell\open\command" and "HKEY_USERS\S-1-5-21-3631097902-1330344798-4155269109-1000_Classes\https\shell\open\command" to ""c:\cygwin\bin\bash.exe" --login /home/Morgan/browser.sh "%1"". I had to do it manually, because the Control Panel interface will only allow you to pick programs that have already been registered as browsers. – Morgan May – 2013-01-11T06:36:47.757