[Mono-list] shell does not work on Widnwos Vista

Stephen Liu satimis at yahoo.com
Tue Apr 27 13:17:40 EDT 2010


Hi Chris,


> The command prompt does a bit of trickery so that 
> you can "run" shortcuts.  The Windows APIs Mono uses 
> to start programs don't do such magic.


On Window Vista I have created a shortcuts of IE on;
C:\Program Files\Internet Explorer\iexplore.exe

rename it as iexplorelnk and put it on;
C:\Users\satimis\


Afterwards on "Command Prompt" executing iexplorelnk starts IE.  But on the window of my small program, "shell.exe", it still fails.  However following commands;

cmd
explorer (Windows explorer)
calc (calcultor0
ipconfig
etc.

which work on "Command Prompt" also work on my program.  But on the top box of the small window I must type;

explorer explorer
calc calc
ipconfig ipconfig
etc.

to make them work.  The command must be repeated otherwise the small window will crash.

I can't understand.


Hereinbelow is the code of MainWindow.cs
// MainWindow.cs created with MonoDevelop
// User: satimis at 10:33 AM 4/26/2010
//
// To change standard headers go to Edit->Preferences->Coding->Standard Headers
//
using System;
using Gtk;

public partial class MainWindow: Gtk.Window
{    
    public MainWindow (): base (Gtk.WindowType.Toplevel)
    {
        Build ();
    }
    
    protected void OnDeleteEvent (object sender, DeleteEventArgs a)
    {
        Application.Quit ();
        a.RetVal = true;
    }

    protected virtual void onButtonRunClicked (object sender, System.EventArgs e)
    {
        string[] strCmmd = entry1.Text.Split(' ');
        
        System.Diagnostics.Process process = new System.Diagnostics.Process();
        process.StartInfo.UseShellExecute = false;
        process.StartInfo.RedirectStandardOutput = true;
        process.StartInfo.RedirectStandardInput = true;
        process.StartInfo.RedirectStandardError = true;
        
        process.StartInfo.FileName = strCmmd[0];
        process.StartInfo.Arguments = strCmmd[1];
        
        process.Start();

        textview1.Buffer.Text = process.StandardOutput.ReadToEnd();
        
        process.WaitForExit();
        
        
    }
}
- end -


This is only test created on learning C#

Any advice?  TIA


B.R.
Stephen





----- Original Message ----
From: Christopher David Howie <me at chrishowie.com>
To: Stephen Liu <satimis at yahoo.com>
Cc: mono-list at lists.ximian.com
Sent: Tue, April 27, 2010 8:26:28 AM
Subject: Re: [Mono-list] shell does not work on Widnwos Vista

On 04/27/2010 07:10 AM, Stephen Liu wrote:
> On Windows Vista, create a shortcut of IE and rename it as;
> 
> \Users\satimis\iexplore.lnk
> 
> 
> iexplore.lnk works on "Command Prompt" window but didn't work on "mono Command Prompt" nor on my small program.

The command prompt does a bit of trickery so that you can "run"
shortcuts.  The Windows APIs Mono uses to start programs don't do such
magic.

In short, unless the program is in your PATH, you can't run it without
specifying the full path to it.  This is not any different than on Linux.

(To introduce another side-case, note that Start>Run also looks in the
HKEY_CLASSES_ROOT\Applications registry key.  I'm still not sure exactly
how MS sells this kind of overconfigurability a benefit, but meh.)

In short, Process.Start() is not exactly the best place to experiment
with if your goal is to create a truly cross-platform application, since
it has platform-specific semantics.

-- 
Chris Howie
http://www.chrishowie.com
http://en.wikipedia.org/wiki/User:Crazycomputers

PGP key:

pub   2048R/CF8338F5 2010-04-14
      Fingerprint: 2B7A B280 8B12 21CC 260A  DF65 6FCE 505A CF83 38F5





More information about the Mono-list mailing list