Welcome Guest! To access all forums & features, please register an account or sign-in. → Why register?



[C#] Process.Start with current path?


7 replies to this topic - - - - -

#1 Joni_78

    Neowinian Senior

  • 1,915 posts
  • Joined: 19-April 04
  • Location: Finland

Posted 26 November 2012 - 09:08

My JavaScript sends a selected path, for example C:\files to com ActiveX, I catch it on C# like this:
[ComVisible(true)]
  public string MyParam
  {
   get
   {
    return myParam;
   }
   set
   {
    myParam = value;
   }
  }

I then launch a program like this:
[ComVisible(true)]
	    public void LaunchPlayer()
	    {
		    Process.Start("wmplayer.exe", "ANYFOLDER");
	    }

The problem is that how do I launch the program so that it uses the current value on myparam on "anyfolder"?


#2 ffMathy

    C# .NET guru

  • 187 posts
  • Joined: 21-January 11
  • OS: Windows 8

Posted 26 November 2012 - 09:23

View PostJoni_78, on 26 November 2012 - 09:08, said:

My JavaScript sends a selected path, for example C:\files to com ActiveX, I catch it on C# like this:
[ComVisible(true)]
  public string MyParam
  {
   get
   {
	return myParam;
   }
   set
   {
	myParam = value;
   }
  }

I then launch a program like this:
[ComVisible(true)]
		public void LaunchPlayer()
		{
			Process.Start("wmplayer.exe", "ANYFOLDER");
		}

The problem is that how do I launch the program so that it uses the current value on myparam on "anyfolder"?
Wicked. Do people still use ActiveX? I have no experience in that what so ever. Have you tried Stackoverflow?

#3 stumper66

    Neowinian

  • 58 posts
  • Joined: 08-January 09
  • Location: Dallas, TX, USA

Posted 26 November 2012 - 13:35

	    public void LaunchPlayer()
	    {
		    System.Diagnostics.ProcessStartInfo PSI = new System.Diagnostics.ProcessStartInfo();
		    PSI.FileName = "wmplayer.exe";
		    PSI.WorkingDirectory = "C:\\MyDirectory";
		    System.Diagnostics.Process.Start(PSI);
	    }


#4 georgevella

    Software Developer

  • 967 posts
  • Joined: 15-May 02

Posted 26 November 2012 - 13:48

Unless I understood the OP's question incorrectly, this should do the trick:


Process.Start("wmplayer.exe", myParam);

The second parameter specifies the arguments passed to the executable. If you want to launch the executable with a different working directory, you should follow stumper66's suggestion above and set the WorkingDirectory property accordingly.

#5 OP Joni_78

    Neowinian Senior

  • 1,915 posts
  • Joined: 19-April 04
  • Location: Finland

Posted 26 November 2012 - 20:18

Thanks.

#6 OP Joni_78

    Neowinian Senior

  • 1,915 posts
  • Joined: 19-April 04
  • Location: Finland

Posted 27 November 2012 - 10:43

View PostffMathy, on 26 November 2012 - 09:23, said:

Wicked. Do people still use ActiveX? I have no experience in that what so ever. Have you tried Stackoverflow?

Is there anything better that I can use? I use ActiveX so that I can send parameters from javascript to methods in .dll.

#7 georgevella

    Software Developer

  • 967 posts
  • Joined: 15-May 02

Posted 27 November 2012 - 11:11

View PostJoni_78, on 27 November 2012 - 10:43, said:

Is there anything better that I can use? I use ActiveX so that I can send parameters from javascript to methods in .dll.
From the way you are using it, doubt there is another way other than COM (am I wrong to assume you are actually using COM and not ActiveX which is a variant of COM/OLE and used primarily for shared UI controls?)

#8 +Majesticmerc

    Resident Idealist

  • 5,105 posts
  • Joined: 24-August 05
  • Location: United Kingdom
  • OS: Arch Linux / Win 7
  • Phone: HTC One X

Posted 27 November 2012 - 13:37

Out of curiousity, why are you using JavaScript in the first place?