Jump to content



Photo

[C#] Process.Start with current path?


  • Please log in to reply
7 replies to this topic

#1 Joni_78

Joni_78

    Neowinian Senior

  • Joined: 19-April 04
  • Location: Finland
  • OS: Windows 8 Pro with Media Center
  • Phone: Nokia Lumia 920

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

ffMathy

    C# .NET guru

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

Posted 26 November 2012 - 09:23

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

stumper66

    Neowinian

  • 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

georgevella

    Software Developer

  • 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

Joni_78

    Neowinian Senior

  • Joined: 19-April 04
  • Location: Finland
  • OS: Windows 8 Pro with Media Center
  • Phone: Nokia Lumia 920

Posted 26 November 2012 - 20:18

Thanks.

#6 OP Joni_78

Joni_78

    Neowinian Senior

  • Joined: 19-April 04
  • Location: Finland
  • OS: Windows 8 Pro with Media Center
  • Phone: Nokia Lumia 920

Posted 27 November 2012 - 10:43

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

georgevella

    Software Developer

  • Joined: 15-May 02

Posted 27 November 2012 - 11:11

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

Majesticmerc

    Resident Idealist

  • Tech Issues Solved: 5
  • 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?



Click here to login or here to register to remove this ad, it's free!