On Sep 20, 2006 5:42 AM, Carlos M wrote: > On Windows if you open a command prompt window and type > "start http://www.google.com" it will show the page in the > default web browser (IE, FireFox or anything else). > > The problem is that I couldn't get it working with RB's > Shell.Execute - it gives always error -2. I'm not > experienced on using shell commands on RB with Windows, > so I might be doing something wrong.
And I was right - I was not setting the Shell.Mode to asynchronous or interactive but this is not the solution for the original problem Dave Wooldridge had <http://support.realsoftware.com/listarchives/realbasic-nug/2006-09/ms g00734.html> as the IDE Script DoShellCommand is executed in synchronous mode and using "start http://www.google.com" on Windows only works in asynchronous or interactive mode. Anyway, and just for the record, here's 2 ways to show a URL in the default browser on Windows using the Shell class: 1. Without using a window property: Dim s As Shell s = New Shell s.Mode = 1 s.Execute "start http://www.google.com" 2. By using a Shell object as a window property (similar to the LR's last example): a) Add a Shell object as a property of a window Protected mShell As Shell b) On the window open event initialize the Shell: mShell = New Shell mShell.Mode = 1 // the LR example uses 2 (Interactive) c) Then use (on a PushButton for example): mShell.Execute "start http://www.google.com" Mode must be set to 1 (Asynchronous) or 2 (Interactive). Note: If the user is using a Firewall it might display an alert everytime this code is used - it does with ZoneAlarm. Tested on Windows 2000 with 2005r4 and 2006r4. BTW, the LR is wrong when it says that "Interactive mode is supported only on Mac OS X." - it is also supported on Windows and the "Example Projects\Shell" has an example on how to use the Interactive mode on Windows. This error was already reported on 2006/03/08 - report id: sedxswgo Carlos _______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives of this list here: <http://support.realsoftware.com/listarchives/lists.html>
